2D Graphics Programming Project, 2009-10
The purpose of this project is to create a small object-oriented program that creates graphics using OpenGL and handles user-interactions from mouse and/or keyboard.
Figure 2: A rough sketch of the lunar-Lander screen.
This option is a lunar-lander game and follows the usual scheme for games like this. At the start of the game a landscape (the squiggly line) is drawn and a landing craft positioned near the top of the display. The aim is to land the craft softly enough with the added difficulty that there is only a limited amount of fuel.
The craft is controlled by two forces:
- Gravity: there is a constant downward force on the lander which results in acceleration towards the ground). If the craft has X and Y ordinates and DX and DY velocities (these would be represented as float variables in the object), the action of gravity over successive time-slices would result in:
DY += G (G is some gravitational constant)
- Thrusters: the player of the game has thrust control in both X and Y directions. Setting DX to some value, it will remain at that value until the craft hits the ground or additional thrust is applied (to speed it up, slow it down or reverse its direction) – that allows manoeuvring left and right to a safe (i.e. near-flat) landing zone. DY thrust can only be upwards, and is used to counteract gravity. Since it is a force, it produces acceleration upwards. At any given time, the upwards/downwards motion will be set by an acceleration equal to the sum of gravity + thrust in the Y direction (note, gravity and thrust oppose each other, so it is really a subtraction), and this will set the amount to add to the vertical velocity (DY) in each time slice. Note, each pulse of thrust will reduce the fuel available (more so in the vertical direction since it needs to counteract gravity). When fuel runs out, the craft will fall to the ground and if it does so at an excessive speed, it will crash-land.
In your game, you can choose how to draw the landscape (drawing code or bitmap), and the lander, and use trial and error to work out good levels for thrust control (possibly different in horizontal and vertical directions) and gravity. You also have a choice of whether to keep the craft in the middle of the screen and move landscape left and right (this requires a bit of work to arrange for a landscape that is wider than the actual screen) or keep a steady landscape and move the craft left and right (the easy option). Your aim should be to create a dynamically interesting game that is playable but not too easy.If you wish,you can add a ‘heads -up ’ display of speed,fuel left etc.somewhere on the screen.
If you find all of this too easy, there is a lot of scope for random meteorites that can destroy the lander, having only small areas where the ground is flat enough to land etc. The interest in the gamewill normally come from it not being a push-over.