Pacadaman is a simple implementation of the Pacman game written in ADA.
The decisionWe had to make an ADA project for school and we wanted to make a game in order to do a funny project. The Pacman game was the perfect idea with the hardware we had: a STM32F4 board which includes a touch screen.
The GameThis program takes up the general idea of the original Pacman game. You are a player which moves in a map and tries to get all the coins in the map. In the mean time, there are multiples enemies that can "eat" you if you come close to them.
The rules are nearly the same:
- You (the player) always start at the same place (at the left of the map)
- The enemies are generated at the start of the game with a random position
- The enemies move randomly except when the player is within 3 blocks, then they will chase him as long as they see him
- At the beginning, the player moves upwards
- The touch screen is splitted into 4 triangle regions that corresponds to the 4 possible directions
- The player moves automatically in the previous indicated direction as long as he can (when there is no wall in this direction)
- When you indicates a direction going into the wall, this direction is saved until a new one is given and the program tries to use it for each move
- When the player goes out of the map, he reappears at the opposite side
- If the player touches an enemy, he loses the game
- If the player gets all the coins, he wins the game
We decided to take the same map as the original game. The difference is that our map is bigger to match the size of the screen and to bring the most immersive experience that you can have on a screen like this.
The codeThe code is written in ADA. Some pre/post conditions are written to make sure that the code runs correctly. The code is entirely written by
How to compileIn order to use our project, you just need a STM32F4 board with a touch screen.
To compile this project, you will need:
- The ADA drivers library: https://github.com/AdaCore/Ada_Drivers_Library
- The GNAT community 2018 tool suite for ARM: https://www.adacore.com/download
Then, you will have to modify and set your PATH and GPR_PROJECT_PATH variables:
export PATH=$PATH:/path/to/GNAT/2018-arm-elf/bin
export GPR_PROJECT_PATH=/path/to/Ada_Drivers_Library
Using `grpbuild` you can build the project:
gprbuild -Pprj.gpr
And then flash to the board using `st-flash`:
st-flash --reset write main.bin 0x08000000
Video
Comments