Author: Yun-Jui Hsieh
Instructor: Daniel Mikesell
The Pharaoh’s Escape: A Maze Stimulation
Using a joystick and mouse to enjoy the story and escape from the pyramid-like maze on the screen.
After entering the game from Processing, a pharaoh figure will appear on the screen and the player has to click on the start button to continue the game. The screen of the story will show, and the following screen will tell the players about the rules and notes. Then it will take the player to the gaming screen, which has a pyramid-like maze and a movable pharaoh figure, and the player can use the joystick to move the pharaoh figure. Moreover, the wall will block the figure from crossing the wall, so the player must follow the specific track to finish the game. If the player makes the exit within 100 seconds, then the gaming screen will be changed to success screen which shows a rotating pharaoh and the word “Congrats,” otherwise if will be changed to failure screen that has a restart button, which allows the player to start over again and again.
The Whole Project
Initially, I wanted to make an extension of my stupid pet trick. I made a “cupholder for lazy people” for that project, and I wanted to add another servo to make it work better. However, my professor turned this proposal down, saying that the midterm project “is about application, not necessarily about the complexity of coding or the items.” He asked me to think about something interactive and related to art, so I started finding some examples of interactive art online. After viewing several picture online, I got the idea of making a delicate LED pedestrian traffic light, whose human figure can move and walk instead of standing still. However, after deeper consideration, I found three difficult problems of the idea that is nearly impossible for me to conquer. First, it is not interactive enough. Second, the DFRduino board might not be able to process such a complex code. It does not have enough holes that I can connect to. Third, the idea is not new. Although the human figure of pedestrian traffic light in Shanghai does not move, it is “movable” in Taiwan, my hometown, for several years. Since it is not innovative, as well as the lack of skills and equipments, I finally gave up this idea.
Then I started thinking about something that can be both displayed on the computer screen and controlled by buttons. The idea of making a maze suddenly stroke me— I can’t remember where this idea came from— so then I started to search for some images online. The idea was approved by my professor in the second individual meeting (03/22/2017), and he told me that I needed to do “collision detection (by color),” so then I stated working on it.
I chose to make a triangle maze at first because I thought rectangle one was not challenging and creative enough. I finished a triangle maze in the following day (03/23/2017) after computing the positions of the lines. In addition, I even composed a simple story about the maze. (Story: the triangle figure is actually a pyramid. One day, an old pharaoh was accidentally buried in the pyramid during his deep, deep sleep. After he woke up, he found himself buried, so he had to escape from the pyramid within 100 seconds, or the entrance would be closed forever!) Moreover, I drew a pharaoh, which acts as the main character in the game. By the way, the pharaoh is made of several quadrangles and lines.
First Maze (Triangular)
After finishing the maze and the movable item, the pharaoh, on Friday (03/24/2017), I started to work on “collision detection.” I worked with Luis, and we tried to use the exact positions of the lines to detect collision. However, since nearly all values (x and y) of the lines are not rational, we couldn’t make effective detection. Therefore, after several hours of struggling, I decided to draw another triangular maze which is made of vertical and horizontal lines. I made another maze on Saturday (03/25/2017).
Second (Final) Maze
However, making collision detection by detecting the exact values was still hard, so I asked Jiwong if I could detect by color as what professor Mikesell suggested. Therefore, she taught me how to use “get” function and some basic ideas about pixel. I used to arrow buttons on my computer then, so we only chose four points (because there are only four directions!) around the pharaoh figure’s mouth to do color detection. Finally we made successful collision detection (03/27/2017).
Collision Detection (The detecting points was lower, so it may be confusing at first)
After making collision detection, I started to think about “game logic.” I needed a beginning as well as a ending screen for the game, and I also needed several buttons that brings players to the story screens, the gaming screen, and the restart screen. I asked Luis and Antonius, and they asked me to create several new functions, such as “Successscreen” and “Failscreen,” so that the game can be actually “ended” and “restarted.” Also, I used “if statement” to create several rectangular buttons and used “text” function to type words like “start,” “go” and “restart” on the screen. By the way, the starting screen has a frightened pharaoh figure whose eyeballs are missing, the success screen has a rotating pharaoh figure with its eyeballs, and the failure screen is also a restart screen, which has a big restart button in the middle (03/28/2017 & 03/29/2017).
Final Code on Processing
So far, the Processing side is ready; however, on the Arduino side, our serial code didn’t work. Several days ago, Maya tried to make a tilt sensor, but it simply didn’t work then. We tried to use buttons next, but first, the direction was always wrong, and second, it was not entertaining enough. Finally, we chose to use joystick instead, trying to make our project more interactive. After several hours of research, Maya finally found out the solution, so the joystick can move the pharaoh figure on the screen.
Maya decorated the joystick box afterwards, using some pictures of scarab and bricks to decorate it. In ancient Egyptian myth, scarab would lead the dead person to be alive again, so it makes more sense since we have to rescue the dying pharaoh in our game. Also, using picture of Egyptian bricks allows people to know more about our project at first side, so that is why we chose to use these two elements to decorate our controller.
Collision detection is the most difficult technique I have learned in this project. However, there is still one flaw in my collision detection. Initially, I used arrow keys to control the pharaoh, therefore I used merely four points to detect the lines. They are on the top, down, right, left parts of the pharaoh’s mouth. However, we changed the controller to joystick at last, so the detection points sometimes do not work for it. Since joystick can give two values (e.g. up and left) and the same time, the moving object can move diagonally, thus sometimes it crosses the wall since the is no detecting point on the corners. It works fairly well for the most of the time, but sometimes it crosses the wall accidentally.
After doing this project, I have gained a lot of knowledge about Processing. I learned the importance to put codes in the right loops and right order, and learned the way to use some new, unfamiliar functions, such as “get()” and “class.” The improvement in the ability of coding on Processing is the most valuable things I got from doing this project.