Picaxe Game System


Merry Christmas everyone - In the spirit of giving and Christmas I'd like to share a project i've been working on recently with the community.

I'm referring to the project as a Picaxe Game System. In short terms think of it like a gameboy or similar. The system consists of

  • A 4D systems uLCD for display (serial version)
  • 6 Buttons (Up, Down, Left, Right, Start, Select)
  • A 5v regulator. The game consists of
  • A 28x2 containing the current game
  • A 24LC256 providing the memory for the game.

As you can see the system itself contains no brains, i did contemplate including brains, but decided that would simply slow the system down and add unnecessary overheads.

Anyway, the game:

The first game I have implemented is a recreation of the old Lunar Lander game, 2D landscape, have to land the LEM on a specific spot, not too fast or you crash, you know the sort of thing.

The landscape is stored in the attached EEPROM. It is known that the display is 320 px wide, well in the eeprom positions 0-320 each have a height value stored in them. This height value is then read by the 28X2 one at a time, and then used to turn on one px at a given height. Once all 320 px are on the terrain is generated. The landing pad is stored after the terrain height values by storing the starting X position and the width of the pad.

The lander's speed is stored as a word with values over 32768 being speed upwards (that is rising) and values below 32768 being speed downwards or falling.

The lander's change is speed if the engine is not on is just speed = speed - gravity, if the main engine is on then it becomes speed = (speed - gravity) + engine Power.

This is done to allow different levels simply by varying the gravity and engine power ratio. It also allows inertia by taking several updates to return to a positive speed after an extended fall.

Variable acceleration is nessescary to give the appearance of gradually speeding up, as would happen in the real world. This is achieved through a loop that controls the frequency of updates in position depending on the lander's speed.

Finally collision detection is achieved by storing the height of the 15 pieces of terrain under the lander in 15 variables (lemLand0...) If the yPosition of the lander is greater than any of these variables a crash is detected (greater as 0,0 is the top left corner of the display)

Once a collision is detected checks are conducted to determine if the landing was in the correct position and below a certain speed a safe landing and congratulations is displayed. Otherwise a crash has occured and the screen is turned red to simulate this.

Print Page