Homework 6

Due Monday 25-Feb, at 8pm


IMPORTANT NOTE: We are not providing a starter file this week!

While you may submit to Autolab as often as you like for this assignment, there is no autograded portion, so you will be responsible for testing your code and making sure it meets the problem requirements. As stated in the style guide, you do not have to write test cases for interactive, random, graphics, data initialization or event functions. Instead, you should test by visually inspecting your code’s behavior as you complete steps of each problem, where reasonably possible. This will make debugging your code much easier.


  1. Mentor Meeting [0 pts]
    You are required to meet with your mentor every week. Failing to meet with your mentor will result in -5 on the assignment. Remember, a mentor meeting is a quick, in-person checkin before the submission deadline of this assignment. The goal of the mentor meeting is to see how you are doing, get feedback, and provide advice and tips for the class.

  2. COLLABORATIVE: Tetris [50 pts] [manually graded]
    Write Tetris according to the design given in this step-by-step tutorial. You may not use a different design, even if you think there's a better way to do it (there probably is, but you still have to do it this way). This may seem limiting, but sometimes you have to write code according to a specific algorithm, rather than writing code to solve a specific problem.

    To get full credit, you'll need to complete the basic implementation according to the design spec. Please write this basic version (WITHOUT extra features) in hw6-tetris.py.

  3. targetsGame [50 pts] [manually graded]
    Using tkinter and the animation framework we've learned about in class, implement the Targets Game. The goal of this game is to click on as many targets as possible before time runs out.

    For a video walkthrough of the game's requirements, watch this video.

    You do not have to implement the game as shown in the video pixel-perfect. However, we will expect that your game contains the following features:
    • Three main states: the start screen (which shows introduction text and a bouncing target), the game screen (where you actually play the game), and the game over screen (which displays the final score and ends the game)
    • In the start state:
      • The screen should display text showing the game's name and instructions for how to start
      • The player should not be able to interact with the game at all, except by pressing 'p' to play (which brings the player to the game state)
      • There should be one infinitely bouncing target, which should not go offscreen at all. The target should contain five cocentric circles which alternate red and white.
    • In the game state:
      • Gameplay takes place in a rectangle that is 2*data.width x 2*data.height in dimensions. When you start the game, the view is centered in the middle of that rectangle. The rectangle is surrounded by a black border with thick walls.
      • To move around within the rectangle, press the arrow keys. Pressing an arrow key moves the screen in the correct direction by a tenth of the screen's width/height.
      • A new target should appear in a random location within the rectangle every 0.5 seconds, with a randomly-chosen radius (where the radius can be 5 pixels, 15 pixels, or 25 pixels). Targets should always appear fully within the rectangle (not outside of the black border), and are allowed to overlap each other. Targets should be displayed the same way as the bouncing target on the start page, but should not move.
      • Whenever the player clicks on a target, that target disappears and the user gets 1 point. If the player clicks on a spot where two targets are overlapping, only the outermost (most recently added) target disappears. Also, the player must click on the target itself for it to appear; if the player clicks within the target's bounding box but outside of the outermost circle, that should not count.
      • The player's score should be displayed in the lower left corner of the screen
      • The player starts the game with 20 seconds remaining to play. However, every five targets that the player clicks on adds 1 second back to the clock.
      • The time remaining is shown in the upper left corner of the screen, and can be rounded down to the nearest integer. This means that the clock will show 0 seconds when there's actually still time left; that's okay for now.
      • The game ends when the time remaining reaches 0 seconds. At that point, the game should switch to the game over state.
    • In the game over state:
      • The background should be red, with white text
      • The screen should display text stating that the game is over, showing the player's final score, and showing instructions for how to play again.
      • The player should not be able to interact with the game at all, except by pressing 's' to start again (which brings them back to the start screen)

    That's it. Have fun!