CMU 15-112 Spring 2018: Fundamentals of Programming and Computer Science
Homework 11 (Due Friday 6-Apr, at 6pm)



  1. 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:

    Mon4:30pmGHC 4307Multiplayer (Sockets)
    Mon5:30pmDH 1112Machine Learning (slides)
    Mon7:30pmMM A14Module: Pygame (slides)
    Tue4:30pmPH 1003D Graphics (slides)
    Tue6:30pmDH 1112Databases
    Tue8:30pmDH 1112Game A.I. (slides)
    Wed4:30pmPH A18AData Analysis (notes)
    Wed5:30pmPH A18AModule: PyAudio (slides)
    Wed6:30pmPH A18AModule: openCV (slides)
    Wed7:30pmDH 1112Hardware
    Wed8:30pmDH 1112Functional Programming (slides)
    Thu4:30pmDH 1217Facebook Poke Bot (slides)
    Thu5:30pmDH 1217Data Structures (slides)
    Thu6:30pmGHC 4307Animation without MVC
    Fri4:30pmDH A302Graph Theory
    Fri5:30pmDH A302Android
    ---------Kinect (slides)


  2. 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.

  3. 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.