Homework 5

Due Wednesday 12-Feb, at 9:00pm


To start

  1. Create a folder named hw5
  2. Inside that folder download the CMU Graphics.
  3. Create a file named hw5.py (We are not providing a starter file this week.)
  4. Edit hw5.py and build the game as described below.
  5. When you have completed and fully tested hw5, submit hw5.py to Gradescope. For this hw, you may submit up to 999 times, but only your last submission counts.

While you may submit to Gradescope as often as you like for this assignment, and the game is not autograded. 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.

Some important notes

  1. This homework is solo. You may not collaborate or discuss it with anyone outside of the course, and your options for discussing with other students currently taking the course are limited. See the academic honesty policy for more details.
  2. Do not hardcode the test cases in your solutions.
  3. Remember the course’s academic integrity policy. Solving the homework yourself is your best preparation for exams and quizzes; cheating or short-cutting your learning process in order to improve your homework score will actually hurt your course grade long-term.

Limitations

Do not use sets, dictionaries, try/except, classes, or recursion this week. The autograder (or a manual CA review later) will reject your submission entirely if you do.

A Note About Style Grading

Like in the previous assignment, we will be grading your code based on whether it follows the 15-112 style guide. We may deduct up to 10 points from your overall grade for style errors. We highly recommend that you try to write clean code with good style all along, rather than fixing your style issues at the end. Good style helps you code faster and with fewer bugs. It is totally worth it. In any case, style grading already started, so please use good style from now on!

Problems

  1. Bounce Football [100 pts, manually graded]

    Build the game bounce football, as described in the following video:


    Take note of the following specifications:
    1. The ball should start at a random location along the edge of the arena. (The location should be randomly chosen whenever the game is played.)
    2. The overall resolution of the game window is 800x600.
    3. The ball has a diameter of 40 pixels.
    4. The green and blue goal lines each have a width of 40 pixels.
    5. When the user clicks anywhere in the window, a wall is drawn at that location.
    6. By default, a horizontal wall is drawn. However, if the user presses 'v' then the future wall will be vertical instead of horizontal. If the user presses 'h' then the future wall will once again be horizontal. Which wall placement mode the player is in should be printed along the bottom of the screen.
    7. There is only one player-defined wall at a time. When a new wall is placed, the previous one is removed.
    8. The ball bounces off of the arena walls and/or the extra wall drawn by the player.
    9. It is considered a goal if the ball touches any part of either goal line.
    10. When a goal happens, the game stops and the Game Over screen appears.
    11. The player can press 'r' to reset the game and play again.

    If you aren't sure about some functionality or appearance, check the video. For minor things related to the look and feel, make whatever choice you think is best. (For example, in choosing the font size for the text at the bottom or choosing how much space to leave between the arena and the edge of the screen.)