During my first semester at Georgia Tech, I am taking an interactive prototyping class, where we cover interactive UIs and then physical prototyping with Arduino boards. The first half of the class focuses on software prototyping, and we used the Processing library and IDE to develop UIs with various interactivity.
For a final project for this section of the class, we were asked to create a video game that could be played on a PC. The specifications for the assignment were as follows:
- The game must have 3 levels with progressing difficulty
- The game must use 1 image and 1 sound file, implemented through the PImage and Minim libraries
- The game must have some scoring system
- The user must be able to play the game through the keyboard and mouse
Link in a Maze
Although I don’t identify as a gamer, if I had to pick my favorite video games, they would be the Legend of Zelda series. For this game, I wanted to make my own Legend of Zelda game, and designed my own little version of Link, the main character.
In my game, Link must collect the three pieces of TriForce, which are small triangles located at the end of a maze. In the later levels, there are additional challenges or opportunities for Link to gain points.
The Maze Environment
Implementing the maze was the most difficult part of this project because of how Processing treats lines. While there are inbuilt functions in the library to draw lines, lines are collections of pixels, not objects, so I had to implement my own collision detection.
I started by first drawing the maze by hand on graph paper, and identifying the endpoints for each line. Processing treats the display like a cartesian plane, where each point is a pixel. Then while coding each line, I identified which pixels were “wall pixels” in a separate boolean array, and used that to detect whether Link was within a certain distance of any pixels labelled as “wall pixels”.
While working on this project, I looked at many resources online for collision detection in Processing, but it seems that this was the most efficient way. Most of the algorithms online suggested continuously checking whether the character was crossing each line along the x- and y-axis, but this would extremely inefficient, considering how many horizontal and vertical lines there are in the maze. My implementation involved 4 simple IF statements – 1 for each direction Link could move.
Level 1 requires the user to simply navigate the path through the maze to collect the piece of TriForce at the bottom right corner of the display. The user can move Link using the directional keys on the keyboard.
In level 2, Link can collect ChuChu jellies along his path, which increase his score in the game. To collect a jelly, Link simply has to walk into the jelly, which is similar to how Link collects objects in the original Legend of Zelda games. In the end, he must collect the 2nd piece of TriForce, which will take him to the next level.
In this level, I used images of ChuChu jellies from the original games, and included a bell sound to indicate that Link had collected the jelly. The references for these files were included in the documentation I submitted with the project.
In the final level of the game, Link must also fight ChuChu monsters, which are also enemies in the original games. To attack a ChuChu monster, Link must strike it with his sword. To draw Link’s sword, the user must press SHIFT and strike the monster on the head. If Link gets too close to the ChuChu monster, he loses points; striking a monster gains him additional points.
In this level, I also used images of the ChuChu monsters, and added the reference to the source files in my documentation.
End to End Game Play
Here is a sample game play showing the 3 levels.