Space Shooter
By: Brent Cowan
I’m planning to build a multiplayer space
shooter at some point with lots of crazy power-ups. But for now I’m just
experimenting with control types and graphics. I created all the graphics
myself although the dirt/rock texture is made from a mix of royalty free tiling
textures and the ship is based on concept art I found online. I modeled the
ship in Maya and used screenshots to build a sprite sheet with 7 frames of
animation. This allows the ship to tilt from side to side while turning.
Packing all the frames into one image allows for
faster load times over loading many smaller files. To display the frames
individually requires a little math:
Sprite.u1 = frameWidth / imageWidth * frame;
Sprite.u2 = frameWidth / imageWidth * (frame+1.0f);
The sprite texture coordinates are specified in
u and v. By default sprites display the entire image (u1
= v1 = 0.0, and u2 = v2 = 1.0). In the example above, there
is room in the image for 8 frames but I only have 7. The first frame (frame 0)
is left blank. Frame 4 shows the ship while it is level. The code to display
this frame in a sprite is shown below:
ShipSpr.u1 =
(ShipImg.width/8.0f)/ShipImg.width * (4.0f); ShipSpr.u2 =
(ShipImg.width/8.0f)/ShipImg.width * (4.0f+1.0f); |