Day 2: Putting ideas in practice


So, after a day trying to prepare the foundations to my game, I realized that, if I were to actually participate in this, I'd have to at least start coding something already. Plus, even though the base system (game-sketch) is not yet finished, it is already good enough to display stuff on screen.

First of all, there is a problem of ultimate importance to my game: there is still no text support. Turns out that the "text" support I programmed back in another CL project was really just a way to display numbers, not full font support.

This font thing is actually a very simple thing: I just type all ASCII characters to a single image file (which I already have generated. I've been using GohuFont for that for at least four years now. And it's always the same image...), in the order they come at the ASCII table, disposed as a grid (left-right, top-down). The actual rendering just involves calculating where each glyph is, as if it were an ordinary texture atlas, and then just show that piece of the texture in an OpenGL quad.

This is not a method I'm proud of, as it could be infinitely be made more efficient, perharps even involving framebuffers or pre-rendering some text as an actual image file, but I don't think I should spend too much time on this right now. Maybe for another occasion.

(Come to think of it, perharps I really should pre-render some text assets and display them onscreen with no extra problems. This way, I could just borrow the number-printing code, which uses the above technique, from my other project, and only use it to show the game score, lives and whatever other numbers).

Anyway, I am here to talk about progress, not only about things that need to be done, right? So here is a video of the game in its current state:


I thought I'd just post a video of it since the graphics are so simple and there is a lot going on. Sure, mostly there is lines and a few dots, but I managed to make it look exactly as I wanted.

I kind of got inspired on an old shoot-em-up game I made back in 2013 for the Windows Phone, using C#/XNA. Then I kind of mixed it a bit with Asteroids. The main mechanic revolves around the fact that you have an infinite vertical plane and, as you move vertically, the ship will shift its angle. This will also affect the trajectory of any projectiles you shoot; as you can see on the video, while they also wrap around vertically, they also copy the current ship angle when shot. The goal of the game will involve using smart ways to pilot and shoot at the same time, since you have to move to shoot angled projectiles. Of course, this demands that I be very careful with level design itself, which I intend to reserve specific time to do.

And last but not less interesting, there's the stars on the background. Though they look so simple, I used a very cool trick I'd like to share.

The game uses a level-of-detail feature. This directly influence the amount of spawned stars in the background (the video is running on low spec). To avoid iterating over every star and performing parallax logic, I created a list of LAYERS. Each LAYER contains a list of STAR COORDINATES, which are generated at random, and remain CONSTANT for the rest of the game -- at least until you change it somehow. The trick here is that I also declare some LAYER MULTIPLIERS which will determine the speed which every layer will "walk". And then, I also declare some LAYER X COORDINATE CENTERS, one for each layer, which will also specify the X center where every star of that layer will be drawn around.

The "update" logic for the stars involve simply adjusting the centers according to the multipliers, and then applying a modulus operation to make sure the value wraps around back to zero, which is the initial state. The rest is done on drawing: for every star, you draw it around that same X center which we estabilished before; however we also apply that modulus operation on the star coordinate so it properly wraps around the X axis as well. This way, if a star is supposed to be drawn after the right boundary of the play area, it is then wrapped and drawn in front of the left boundary, as if the left and the right boundaries were the same line (the plane becomes a cylinder!). Not really something mathematically impressed, but I found it kind of clever. There is also room for optimization, but hey, there is a good start; at least I don't have to iterate over every star twice.

Well, that's it for today. Tomorrow I'll go ahead with my plans and try to come up with a proper heads-up display, maybe even a pause menu. And of course, I'll have to decide about that text support as well, heh.

Edit: And of course, if you want to take a peek at the code, here's the link to the repository.

Get Orbit Defense Strikeforce

Comments

Log in with itch.io to leave a comment.

Awesome! Good luck in the jam! I liked the game idea. I'm waiting to see the final version :D