CS 0447 – Project 2: Frogger
Due: Sunday, November 10, 2013 by 11:59pm
Many video games of the past were programmed directly in assembly language. In this project, we’ll be taking an early Konami video game, Frogger, and making a version in MIPS under MARS.
If you are unfamiliar with the game, you might want to look at the Wikipedia article, http://en.wikipedia.org/wiki/Frogger or find a modern adaptation (or emulated old version) to try it.
The basic idea is that you are guiding a frog through an obstacle course to get to its home. You start at the bottom of the screen and make your way upwards to one of three safe lily pads.
In our version, we will be guiding the frog over moving stones that are floating by in a river of lava.
After your first project, you might be wondering how to get MARS to make something as awesome as a video game. For this, we can thank several graduate students and Dr. Childers for a modified version of MARS that contains a LED display which we can control. The display is an array of pixels (64 x 64) and each LED can be one of 4 colors: off (black), red, green, or yellow/orange.
In later courses, we’ll discuss two strategies for talking to I/O devices from machine instructions. In this case, the pixel display is memory-mapped. This means that a byte in our address space is reserved for each pixel, and that the content of that array is reflected in the output of our display. Learning about the memory-mapped I/O is not the core of the project and so we provide get and set methods for manipulating a pixel at a specified location.
Additionally, the LED display has support for a key pad. It can handle either button presses on the dialog box or you can use the keys on your keyboard (WASD).
You will need to download this special modified version of MARS from the class webpage in order to do this project.
When you wish to use it, go into the tools menu and select “Keypad and LED Display Simulator”. In the window that appears, click “Connect to MIPS”. Then run the program in MARS using the green play button.
|
|
|
|
Your frog is a 2x2 rectangle of green LEDs. It moves +2 in the indicated direction whenever a directional key is pressed.
Initially the frog is centered in the screen in the 8th and 7th rows from the bottom.
The lava is a 48x64 rectangle of red LEDs that will be 8 LEDs from the top and bottom of the screen.
If the frog ever touches a red LED, it is dead.
A stone will be a 8xN rectangle of yellow LEDs, where N is a random number from 8 to 12 generated for each stone.
To span the river, we will need 6 stones to float by. The stones in the 1st, 3rd, and 5th rows will head to the left. The 2nd, 4th, and 6th row stones will head to the right. Each stone will have a velocity (the number of LEDs it moves each time step) that is a random value from 1 to 3. Stones start from offscreen and each time step will move in the proper direction with the proper velocity.
After the stone has moved 2 LEDs away from the edge it started at, a new stone can spawn with probability 10% (generate a random number from 0-9. If it’s 0 spawn a new stone).
You may limit it so that there are never more than 2 stones in a given lane at any time.
|
|
|
|
|
|
|
|
|
|
|
|
A lily pad is a 2x6 rectangle of green LEDS. There are to be three of them, one on the left edge of the screen, one on the right edge of the screen, and one centered between them (23 LEDs from the edge ones). They appear in the 7th and 8th rows from the top of the screen.
To safely make it home, a frog must entirely be in a lily pad, with no part of it hitting the black void between them or outside of the bounds of the screen.
Create a zip file of your source code and a README.txt text file that has your name, your Pitt username and any notes for the TA to help with grading.
Name the file USERNAME-project2.zip
Use the lab submission policies to upload your project.