Bring It! – Bullet Time

One of the most important parts of the entire game is the ability to shoot at the bad guys. For this you’ll definitely be needing some bullets (and I’ll get to the bad guys soon).

I thought adding bullet sprites would be quite complicated because it would involve finding the angle to be fired at, the start position based on the position and rotation of the character sprite, but that turned out to be quite simple in the end.

Rather than use any complicated mathematics I determined that the centre of the character sprite is something that won’t change because the character is on top of a non-moving tower. I modified the file in the Rokon files to include centreX and centreY values. If I eventually let the character sprite move then I will need to make sure that value gets updated, but that’s a very minor issue.

I create the bullet sprite when the user presses the trackball button, or the centre of the directional pad if that’s what the device has. The bullet sprite appears at the centre of the character sprite and has X and Y velocity applied to it like so:



This gets the bullet moving in the direction the character sprite is pointing as is demonstrated in the video.

The next thing on my list is creating some bad guys that can get hit by the bullets. I imagine that’ll be more complicated than I think at the moment, but I hope to be proved wrong. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *