CMU 15-112 Fall 2017: Fundamentals of Programming and Computer Science
Homework 6 (Due Saturday, 7-Oct, at 8pm)

  1. Ask a question on Piazza [10 pts]
    At some point between 8am Monday 10/2 and 8pm Saturday 10/7, ask a question on Piazza about the lab, homework, or coding in general. This has to be a real question! We will check for this after Saturday and will add points on Autolab manually at that point.

  2. Meet with your TA to talk about Term Project ideas [10 pts]
    Before Saturday 10/7 at 8pm, meet with one of your recitation TAs for 10 minutes to discuss your ideas for the term project, as you outlined in the check. TAs will send out details for arranging meetings by Wednesday.

  3. targetsGame [80 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!