Make yer own!

Make yer own!

So you've decided you want to write a game…

  • Home

Our Design Document

Posted in Uncategorized by J Artis
Sep 07 2009
TrackBack Address.

I think it’s time we finalize our Space Invaders design document. This will probably look a bit overblown at first, but the more detail we have, the less we have to guess when we’re putting together our code. As with the entire series of tutorials here, feel free to deviate as much as you wish – but make sure you HAVE a solid design, and don’t deviate too much from yours. I also cannot say that this is completely immutable – it’s subject to change as we go along, or discover things that don’t work (or possibly work better).

So what exactly makes Space Invaders? (Or, in my case, Star Attackers?)

StarAttackers

The game has two major states, playing and not-playing. I’ll describe what happens in my game for both steps.

1.) NOT PLAYING

  • The logo, saying “STAR ATTACKERS!”, displays at the center of the screen.
  • Toward the bottom, centered horizontally, is text saying “Press button to start”
  • The background has stars that scroll by vertically.
  • When the Start Button (which is conveniently also the Shoot Button) is pressed, switch immediately to “Playing” mode.

2.) PLAYING

  • When “Playing” mode is first started, the player has 3 lives – the one in play, and two in reserve. The reserve lives are displayed as icons in the top left corner of the screen.
  • The score is set to zero, and displayed in the top right corner of the screen, right-aligned.
  • The PLAYER object is created at the bottom center of the screen. He has an X and Y position, that reflect his top-left corner, and a WIDTH and HEIGHT, that will give his bottom right corner.
  • 32 ENEMY objects are created, each with an X, Y, WIDTH, and HEIGHT. The enemies are arranged in 4 rows of 8 across, and each row is a different kind of enemy. They should start near the top-left corner, and they should be spaced half of one WIDTH apart horizontally, and half a HEIGHT vertically.
  • Each enemy being a different kind, we also need to store their TYPE. They will alternate between two frames of animation, so we also need their FRAME.
  • The player and the enemies (all of them) start the game in an ALIVE state, so we need to store that as well.
  • The enemies will move every few frames, determined by how many are left. Specifically, TOTAL ENEMIES – ENEMIES ALIVE updates apart they should move and change animation frame.
  • The enemies move righ, one unit at a time, until any enemy that is still alive would go off the screen. At that point, they shift down 1 unit and start moving left.
  • We should also have a scrolling star background here. I like scrolling stars.
  • The player can only fire one SHOT at a time, and it will have an X and Y (and WIDTH and HEIGHT). The enemies, as a collection, can also fire one SHOT with the same properties.
  • Unlike original Space Invaders, for now I’m not going to add any fortifications.

The game update loop should go something like this:

  • (Handle Input Phase)
    • Set the player’s XSPEED to zero.
    • If the player is pressing left, set their XSPEED to -1.
    • If they’re pressing right, set XSPEED to 1.
    • If they’re pressing shoot, and they are not already shooting, create a new shot at their X + half their width.
  • (Update Phase)
    • Add XSPEED to the player’s X. Restrict it to the playfield (zero to playfield width – player width)
    • If this frame is an enemy move frame, add ENEMY SPEED to each enemy’s X. If this pushes them offscreen, subtract ENEMY SPEED from their X, move them down one unit, and make ENEMY SPEED negative (or positive if it already is). Then change the animation frame accordingly.
    • If the player has an active shot, move it up one unit. Test to see if it hit any alive enemy.
      • If it did, make that enemy play an explode animation.
      • Set that enemy’s state to dead.
      • Add 100 points to our score
    • If the enemies have an active shot, move it down one unit, and test to see if it hit the player.
      • If it did, make the player show an explode animation.
      • Subtract one from the player’s lives.
      • If the player has zero lives left, the game is over, go back to the title screen
      • If not, create a new player.
    • If there are no enemies left alive, create a new batch of 32 enemies.
  • (Draw Phase)
    • Draw the star background.
    • Draw the score and remaining lives.
    • Draw the enemies.
    • Draw the shots.
    • Draw the player.

I’m sure there are a zillion small things I’m missing, and if you can think of them, go back and add them. Comment here, and I’ll add them to our collective design, and we’ll build to it.

Share
Leave a Comment
Click here to cancel reply.

Recent Posts

  • Number names in Scrabble scoring
  • Analysis of Sinister Sudoku
  • Finding words for HexWords
  • Considering control schemes
  • What is a “Bad-ass” platformer?
Powered by WordPress | “Blend” from Spectacu.la WP Themes Club