Categories
General

Thousander Club Update: February 5th

For this week’s Thousander Club update:

Game Hours: 262.25 (previous year) + 21 (current year) = 283.25 / 1000
Game Ideas: 616 (previous year) + 0 (current year) = 616 / 1000

I finally hit the point where I needed to refactor and abstract some of my code for the Space Invaders clone. When I tried to start with abstractions, I didn’t have the mental agility or experience to tell me what I needed. Now that I have some concrete code, I know what is working well and what needs improvement.

Until now, my aliens, my bullets, and my ship were all KrSprite objects. In the Kyra Sprite Engine, each sprite holds its own position data as integer coordinates, and so I just used that data to handle movement. It worked fine, except that it wasn’t very precise. If I wanted to move an object by 10 pixels, there was no problem, but if I wanted to move an object 10.1 pixels, I woud lose that precision. The end result was jerky animation and a feeling that there was a lack in the control scheme.

I never liked the idea that my physics code was dependent on the graphical representation, but it worked well enough for me to concentrate on implementing missing features. One of those features is to get the aliens to slow down to a sane speed. To do so, I need to get more accurate updates, which requires a separate set of position variables. It seemed like it was time to create the general-purpose Entity class.

The Entity class that I originally wrote for Oracle’s Eye Prime involved State and Action objects. I didn’t need anything nearly so complicated. An Entity just needs to hold a position and the sprite. In the future, I may abstract it to use a general-purpose Representation, but that’s only because I don’t like the idea of having to include the Kyra header for this class. I’ll abstract it further when I need to do so, but no sooner. I seem to have more success with the iterative changes. B-)

Now that I have this Entity object, I find that the animation and movement can be slower, smoother, and easier to tweak. I can now specify movement speeds in terms of pixels per second instead of using arbitrary numbers that appear to work well.

I started out with updating just the player’s ship. Everything else gets a delta of zero, which is kind of surreal because the aliens still fire bullets at random. The bullets are also frozen in place next to the aliens. Anyway, the player’s ship used to move very quickly between frames, taking a little over a second to travel the width of the screen, but now it takes longer to travel from one side to the other.

I did the same thing with the bullet movement, and finally I applied it to the aliens. Now everything moves at much saner speeds, and I can easily tweak to get the right balance between the ship’s speed, the various bullet speeds, and the alien’s speeds.

2 replies on “Thousander Club Update: February 5th”

It’s good to see you’re making progress! After a few projects like this you’ll have a good understanding of not just how to do some important things, but a good understanding of WHY you’re doing them.

It’ll also feel very nice having completed a few projects. The confidence boost from that should not be undervalued.

Yep, I’m feeling pretty good about the progress of this project. I don’t know how much longer I will be working on it, but it shouldn’t be too much longer before I am polishing up v1.0. B-)

Comments are closed.