Assignment 3: Raspberry Pi Video Game based on J. Kawash - 2014
Assignment 3: Raspberry Pi Video Game based on J. Kawash - 2014
Assignment 3: Raspberry Pi Video Game based on J. Kawash - 2014
Background This assignment will expand your skill set with the Raspberry Pi. It will require that you use the I/O capabilities of the Pi to get button states from and SNES game controller. You will work with a video display controlled by the Pi. Finally, you can use the power of a (slightly) higher level language to develop code that works directly with I/O devices. Your TAs will help you with the required knowledge for the I/O devices. Objective Implement a video game (in C) that requires the player to travel through a maze with the goal of reaching the exit door within a specified number of moves. Solving the maze will require the player to move through the maze, collect keys, open doors that block the path, and open the exit door before the actions remaining counter runs out. Game Logic The game environment is a finite 2D n x n grid (see Figure 1). • Each grid cell contains either a wall tile or a floor ti CPSC 359 – Winter 2014 Assignment 3 Raspberry Pi Video Game 55 points Due March 31st @ 11:59pm (midnight) Objective: Implement a video game that requires the player to travel through a maze with the goal of reaching the exit door within a specified number of moves. Solving the maze will require the player to move through the maze, collect keys, open doors that block the path, and open the exit door before the actions remaining counter runs out.
Actions Remaining: 150 Keys: 0 wall tile floor tile door player start key exit door Figure 1: Example game rendering. – A win condition flag (set if and only if the player opens the exit door) – A lose condition flag (set if and only if actions remaining equals zero) The game transitions into a new state by the player performing an action • Only transition to a new state if the player performs a valid action – Decrement by one the actions remaining counter in the new game state • Action: Move by one cell in one of the four cardinal directions (up, down, left, right) – Move action is valid only if the destination cell contains a floor tile – Results in the players position being set to the position of the destination cell – Moving into a floor tile marked as key will result in: ∗ The number of keys collected being incremented by one ∗ The removal of the key marking on the destination floor tile • Action: Open a door or the exit door with a key – An open door action is valid only if: ∗ Player is adjacent to a wall tile marked door or exit door ∗ Number of keys collected is greater than zero – Opening a door results in: ∗ Adjacent wall tile marked as door or exit door is replaced by a floor tile ∗ Number of keys collected is decremented by one Game Interface Main Menu Screen • The Main Menu interface is drawn to the screen – Game title is drawn somewhere on the screen – Creator name(s) drawn somewhere on the screen – Menu options labeled Start Game and Quit Game – A visual indicator of which option is currently selected • The player uses the SNES controller to interact with the menu – Select between options using Up and Down on the D-Pad – Activate a menu item using the A button – Activating Start Game will transition to the Game Screen – Activating Quit Game will clear the screen and exit the game Game Screen • The current game state is drawn to the screen – Represented as a 2D grid of cells ∗ All cells in the current game state are drawn to the screen ∗ Each cell is square (width = height), and at least 16x16 pixels ∗ 2D grid should be (roughly) in the center of the screen – Each different tile type is drawn with a different visual representation ∗ ie: wall, floor, door, key, exit door, player start and player ∗ Minimally, cells are filled with different colours based on tile type – Actions Remaining and Keys Collected are drawn on the screen ∗ A label followed by the decimal value for each field – If the Win Condition flag is set, display a Game Won message ∗ If the Lose Condition flag is set, display a Game Lost message ∗ Both messages should be prominent (i.e: large, middle of screen) • The player uses the SNES controller to interact with the game – Pressing up, down, left or right on the D-Pad will attempt a move action o Pressing the A button will attempt to perform an door open action – All buttons need to be released before a new action can be performed o Performing a valid action will require the game state to be redrawn – Pressing the Start button will open a Game Menu Main Menu Screen 1a Draw game title and creator names 2 1b Draw menu options and option selector 2 1c Select between menu options using up/down on D-Pad 1 1d Press A button with Start Game selected to start game 1 1e Press A button with Quit Game selected to exit game 1 Game Screen 2a Draw current game state All cells drawn according to interface specifications 5 Actions Remaining and Keys Collected drawn 3 Game Won message drawn on win condition 1 Game Lost message drawn on lose condition 1 2b Draw game menu Filled box with border in center of screen 1 Draw menu options and option selector 2 Erase game menu from screen when closed 2 2c Interact with game Use D-Pad to move player (if move action is valid) 4 Press A button to open doors (if open action is valid) 3 Press Start button to open game menu 1 Press any button to return to main menu (game over) 1 2d Interact with game menu Use up / down on D-Pad to change menu selection 1 Press A button on Restart Game; resets the game 1 Press A button on Quit; returns to main menu 1 Press Start button to close game menu 1 Well structured code 3a Use of functions to generalize repeated procedures 5 3b Use of data structures to represent gamestate,etc. 5 4 Well documented code 5 Total 50pts Table 1: Grading rubric for assignment 3. ∗ Two menu items: Restart Game and Quit ∗ Visually display menu option labels and a selector ∗ Menu drawn on a filled box with a border in the center of the screen ∗ Normal game controls not processed when Game Menu is open ∗ Pressing Start button will close the Game Menu ∗ Press up and down on D-Pad to select between menu options ∗ Pressing the A button activates a menu option ∗ Activating Restart Game will reset the game to its original state ∗ Activating Quit will transition to the Main Menu screen – If the win condition or lose condition flags are set ∗ Pressing any button will return to the Main Menu Evaluation See the grading rubric in Table 1. You may work individually, or with a partner, but no larger groups. Programs that do not compile cannot receive more than 5 points. Programs that compile, but do not implement any of the functionality described above can receive a maximum of 7 points. Submit a .tar.gz file of your entire project directory (including source code, make file, build objects, kernel.img, etc) to your TA via the appropriate dropbox on Desire2Learn. If you are working with group members in different tutorial sections, choose just one TA to submit to. You will also need to be available to demonstrate your assignment during the tutorial of the TA you submitted the assignment to during the week of November 24.