Space Game Dev Blog #3

Two blog posts in 1 day, woo! I got so much done today I figured it’d be worth it to write a second post.

The notable changes today were: implementing items, special abilities (sort of), doors, and moving platforms. For the curious, here’s a little video of the game play so far:

Those pesky jitters…

I’ll write about the changes in order. The first item on the agenda was implementing a moving platform. Seemed easy enough at the time, I thought maybe I could set a list of coordinates for it to traverse through every time an update function was called.

Turns out that using “tweens” is the go-to way for moving sprites in such a manner. This is a sort of animation that travels along x,y coordinates you give it, along with some other parameters (animation style, loop count, yoyo’ing, etc).


Once that was done, I decided to take the plunge into creating doors. Doors are actually relatively easy, all that needed to be done was to listen for an overlap between the hero and the door. If there was an overlap, you’d wait for the down key to be pressed, and then teleport the hero to the desired location. Easy peasy.


The last and most annoying thing I implemented was the jet pack (and consequently the double jump). What a nightmare it was to figure out a surefire way to jump at the correct time. Phaser’s game state is updated tens to hundreds of times a second, so once you press the “up” key, if you had a function fire when the “up” key was pressed, it’d be fired 10’s of times.

What made things worse is that the hero should only be able to jump once until the jet pack is obtained.

I ended up setting a few flags and adding the doublejump function to fire on the event listener that’s fired for the “up” key.


For anyone who cares about the art (or lack thereof), I added a little custom animation when the jet pack is picked up. Here it is, if you didn’t catch it in the video:

2x Scale

One more thing to note. I know there’s a jitter issue with the camera, but I think that’s a pixel rounding issue that’s causing Phaser to do some guesswork and make it look like some pixels are in two places at once. I’m working on figuring out a fix for that.

I’ve got a new enemy to create tomorrow, and I’m hoping to implement locked doors / keys for the future part of the level. Well, that’s all for now.

-Kevin