A two player pacman-ish maze game built as part of the course COP290 under Prof. Rijurekha Sen
Authors : Harshita & Om
- G++, which is a C++ compiler
- SDL 2.0 (We go through installing SDL on a ubuntu system, and give links for other OSs
#install sdl2
sudo apt install libsdl2-dev libsdl2-2.0-0 -y;
#install sdl image
sudo apt install libjpeg-dev libwebp-dev libtiff5-dev libsdl2-image-dev libsdl2-image-2.0-0 -y;
#install sdl mixer
sudo apt install libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 -y;
#install sdl fonts
sudo apt install libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 -y;
git clone https://github.com/omkrishna/COP290-TASK2.git
cd PacMan
make
In single player mode, COP's target tile is the Student itself. HUL's target tile is 2 tiles ahead of the Student. And ELL's target tile takes into account the positions of the Student, COP and HUL, owing to its unpredictable and erratic behavior. It lies in the same line as COP and HUL's target tiles such that HUL's target tile is in the exact middle. However, in multiplayer mode, COP and HUL each chase one Student and ELL roams with respect to the positions of COP, HUL and the two Students. If one Student fails, all Courses turn to Relative Grading and chase the remaining Student.
In case a Student picks up a PoR Pellet, the Courses enter into a Backlog Mode for a few seconds, i.e. all their target tiles are set to their respective corners in the screen - top-right, bottom-right and bottom-left for COP, HUL and ELL respectively. In the event that a Student picks up an Audit Pellet, the Courses enter into 30% Effort mode. Their target tile is the usual, but when they get in the radius of 8 tiles around the Student(s), they idle out and target tile shifts to their respective corners. When all Students in the game have failed, the exit animation pops up where the Courses do a little victory dance (by moving randomly irrespective of the other sprites) before the exit screen. The maze generation logic was done after consulting various available resources for creating random mazes. The usual DFS approach did not produce pacman-like mazes and was immediately discarded. We looked at Shaun Lebron's code (link in acknowledgement) for the initial idea. Though we could follow his logic completely, we did understand that we needed to stack together Tetris-like blocks keeping in mind a few constraints. We decided on a screen size of 27x21 tiles, where each individual tile was 40x40 pixels. The constraints that we decided upon were :
- paths are one tile thick, whereas blocks are atleast two tile thick
- outer boundary is always blocked with a few potential tunnels
- IITD written across the center
- blocks can be rectangles, T-shaped, inverted T shaped, or any variant of L shape
- Lazy Foo's sdl tutorials are a must watch for anyone who wants to try out SDL. Music, Textures, Fonts, TileMaps - this tutorial has everything covered as far as SDL is concerned.
- Shaun Lebron's article on Random Pacman maze generation was a very tough read but gives excellent results. We couldn't follow his code but did get the idea of stacking tetris-like blocks together to generate mazes.
- This Youtube video gives a great insight about the algorithms ghosts follow to set their targets in pacman. Fascinating stuff
- Prof. Rijurekha Sen, for being so helpful and considerate throughout the semester