Man, this class is pretty!

Lecture Notes Six: Building a Video Game

How are we going to do this? We need a plan.

Let's divide the game into two parts:
  • the aliens
  • the turret (with missile)
I propose that we build two functional units:
  • a UFOManager, and
  • a GunManager

The UFOManager will control the aliens. The GunManager will control the defense.

A third unit controls them both: this is not real stuff, it's a simulation, it's our game. Let's call this third functional unit GameManager. It acts as a referee more or less.

GameManager has three roles:
  • initializes GunManager
  • initializes UFOManager
  • receives user input
Any user input detected by GameManager (perhaps a mouse move, or a mouse click) is passed to GunManager, which interprets it, and takes action (if need be).

What do we see? Sprites.

Indeed, we need to have at least three kinds:
  • we need to show a turret
  • we need to show a missile
  • we need to show a UFO
So I suggest three classes:
  • GunSprite
  • MissileSprite
  • UFOManager

Can I draw a picture? Go for it!

Here it is:
Control classes in blue, sprite classes in red.

Six classes. Let me show them to you. Be my guest.

OK, I start with GunSprite.
And with another picture.

Now the code: Actually I need to rework this!

Can you do it a little bit later, not now? OK, here's what we have:
             Moveable      BitmapSprite
                *               |
  Intersect      BitmapLoop
      *            |



                 Applet             Runnable 
                   +                     *
                   |                     |
                   |                     |
                   |                     |


          Moveable                Sprite
              *                      |
Intersect     |       BitmapSprite---+
   |          |        |



Well, at least we get an idea. Yes, we get an idea.

Images: gun.gif, ufo0.gif, ufo1.gif, ufo2.gif, ufo3.gif, ufo4.gif, ufo5.gif.

Last updated: Jan 21, 2002 by Adrian German for T540 NGD