Homework 7
Due (targetsGame) Tuesday 8-Mar, at 10:00pm AND (Tetris) Thursday 10-Mar, at 10pm
To start
- Create a folder named
hw7
- Inside that folder, create two files:
hw7-tetris.py
and hw7-targets.py
. There is no starter file this week.
- Edit each of these files using Thonny, building the appropriate game. Each file should contain all necessary code for it’s respective problem so that we can easily run and grade one problem at a time.
- Submit each file to the corresponding assignment on Gradescope.
For this hw, you may submit up to 999 times, but only your last submission counts.
Some important notes
- For the collaborative task:
- Unlike all other homeworks, this homework has ONE TASK that is collaborative in teams of two (yourself and one other current 15-112 student).
- Collaboration is not strictly required, but is very strongly encouraged.
- You may only work with at most one other student (and they must be currently in 15-112), and you may not switch partners once you have worked with a partner.
- This must be earnest collaboration, with both of you genuinely working together the whole time. It is not acceptable for one of you to do the work, or any portion of the work, and for the other to copy any portion of that work. All work must come from earnest collaboration from both of you.
- Even if you are working with a partner, each of you must submit your own
hw7-tetris.py
to Gradescope.
- Late submissions are not allowed for this task.
- You must write at the top of the file
hw7-tetris.py
your name and the name of your collaborator.
- For the individual task:
- The second task is NOT COLLABORATIVE and must be completed individually, as stated in the course syllabus.
- For the problems that must be completed individually, 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.
- While you may submit to Gradescope 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.
- 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!
A Note About Testing
You will notice that the skeleton file only includes testcases for some of the
functions you are writing. You should write testcases for the others. (You can
find some nice ways to test in the write-up below, but you will need to
translate those to actual testcases.)
Problems
-
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.
-
COLLABORATIVE: Tetris [50 pts] [manually graded, due Thursday 10-Mar, NO LATE SUBMISSIONS ALLOWED]
Reminder: This must be earnest collaboration. You may not copy any code from your collaborator (or anyone else) by any means (electronically, on paper, by sight, etc). All work must be done truly in collaboration, working together, not copying.
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 hw7-tetris.py
.
If you decide to add some more bonus, which we do not require but we heartily encourage (not for the few points you might earn, but rather for the joy of learning and creating), then create a second version of your Tetris file called hw7-tetris-bonus.py
and add your bonus features in this file.
-
targetsGame [50 pts] [INDIVIDUAL, manually graded, due Tuesday 8-Mar]
Using 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!