CMU 15-112 Spring 2018: Fundamentals of Programming and Computer Science
Homework 11 (Due Friday 6-Apr, at 6pm)
- This assignment is SOLO. This means you may not look at other student's code or let other students look at your code for these problems. See the syllabus for details.
- Note: the deadline for this assignment is Friday at 6pm, not Saturday at 8pm! Don't submit late!!
- To start:
- Go to your folder named 'week11'
- Create a file named hw11.py in that folder
- Edit hw11.py using Pyzo
- When you're done, submit hw11.py to Autolab. You may submit as many times as you like.
- TP Mini-Lectures [20 pts]
Attend at least one of the TP Mini-Lectures taught by the TAs this week. You should pick a mini-lecture that's about a topic you might want to use in your term project. The mini-lecture schedule is below:
Mon 4:30pm GHC 4307 Multiplayer (Sockets) Mon 5:30pm DH 1112 Machine Learning (slides) Mon 7:30pm MM A14 Module: Pygame (slides) Tue 4:30pm PH 100 3D Graphics (slides) Tue 6:30pm DH 1112 Databases Tue 8:30pm DH 1112 Game A.I. (slides) Wed 4:30pm PH A18A Data Analysis (notes) Wed 5:30pm PH A18A Module: PyAudio (slides) Wed 6:30pm PH A18A Module: openCV (slides) Wed 7:30pm DH 1112 Hardware Wed 8:30pm DH 1112 Functional Programming (slides) Thu 4:30pm DH 1217 Facebook Poke Bot (slides) Thu 5:30pm DH 1217 Data Structures (slides) Thu 6:30pm GHC 4307 Animation without MVC Fri 4:30pm DH A302 Graph Theory Fri 5:30pm DH A302 Android --- --- --- Kinect (slides)
- OOPy Frogger [80 pts]
Using the animation framework and OOP, implement a very basic version of Frogger. For a video walkthrough of the game's requirements, see the video below.
When programming this game, you must use object-oriented programming to represent the frog, cars, and trucks. Specifically, you must implement:- A Frog class: has at least two methods, move and draw.
- A Vehicle class: has at least two methods, move and collidesWithFrog.
- A Car class: inherits from Vehicle and has at least one method, draw.
- A Truck class: inherits from Vehicle and has at least one method, draw.
Beyond these restrictions, you can implement the game in whatever way makes sense to you. The game must implement the following features of Frogger:- The game has a frog (a brown diamond) that the user can move around the grid using key presses. It starts in the middle of the bottom row. The frog may not move off-board.
- The game exists on a 2d grid of cells, where cells are 30x30 pixels. There must be at least 3 rows and at least 3 columns (so the window must be at least 100px by 100px). The top row consists of alternating grass and blank space, and the bottom row consists entirely of grass. All the middle rows are roads, where odd rows (1, 3, 5, etc.) have cars and even rows (2, 4, 6, etc) have trucks. Cars are blue circles, and trucks are red rectangles that span two columns. There should always be at least a few vehicles moving on the roads, and the roads should never be overcrowded or empty.
- The direction that traffic moves in for each row is determined randomly at the beginning of the game, but then stays consistent through the entire rest of the game.
- The frog starts the game with three lives. Whenever the frog moves onto a space occupied by a vehicle (including both spaces occupied by a truck), or whenever a vehicle moves onto the space occupied by the frog, the frog loses a life and moves back to its starting location. The frog also loses a life if it moves onto the empty space in the top row.
- If the frog loses all three of its lives, a "YOU LOSE!" screen is shown, and the game stops.
- If the frog gets to a grass space on the top row, a "YOU WIN!" screen is shown, and the game stops.
- When the game stops, the cars/trucks must stop moving, and the frog should not respond to user input.
- Bonus: Improved OOPy Frogger [5 pts]
Want to improve your Frogger game? Go for it! Your improved game must still meet the requirements specified above (though you can improve the graphics), but otherwise you may add any features you like. Include a list of all added features in a comment at the top of the file that says "BONUS". We will grade bonus based on the complexity of the features added.