15-112 Fall 2012 Homework 8
Due Sunday, 28-Oct, at
10pmRead these instructions first!
- Parts of this homework are SOLO
and other parts are COLLABORATIVE
(see hw1 and the syllabus for details). Be sure to know which is which, and
when you do collaborate, be certain to list the names and andrew id's of
each collaborator. You may collaborate with different students on
different questions.
- There are no starter files or public or private autograders this week.
- Grading for this homework may be extrapolated based on randomly-selected
portions of your submissions. However, if we notice any missing
portions, these will of course be deducted in any case.
- What to turn in:
- Turn in a single file, hw8.py, that contains all your solutions.
- When this file is run, a Tkinter window should appear, filled with a
canvas. This is your "launch screen". The launch screen should
include some text indicating that the user should press 1 for Tetris, 2 for
Snake, 3 for More Snake, 4 for Line Runner, and 0 to return to the launch
screen.
- At any time, even while playing any of the games and not at the launch
screen, if the user presses any of the keys '0', '1,', '2', '3', or '4', the
respective game (or launch screen) should start running. If the game
is already running, it should start over.
- Also, do not include any global variables in hw8.py, even though the
Snake and Tetris tutorials include them.
- Tetris
- Snake Tutorial
- More Snake
- Bonus: Line Runner
- Tetris Tutorial [40 pts]
Note: this game should run when the user presses '1' from the launch
screen.
This problem is COLLABORATIVE.
You may work in groups of up to 4 students (yourself included). Write
Tetris exactly according to the design given in
this step-by-step tutorial. You may not use a different design (except
for eliminating globals), even if you think there's a better way to do it
(there probably is, but you still have to do it this way).
- Snake Tutorial [30 pts]
Note: this game should run when the user presses '2' from the launch
screen.
This problem is COLLABORATIVE.
You may work in groups of up to 4 students (yourself included).
Carefully follow all the steps in this
step-by-step Snake Tutorial. Of course, you are ultimately given
the answer in the tutorial. Even so, while you may consult that
solution, you may not simply copy and submit that version, but instead you
must work through each step carefully and then submit the version that you
typed in (and hopefully completely understood, from first principles)
yourself, even if it is basically the same as the solution (as one would
expect). Be sure to list your name and andrew id and those of your
collaborators (if any) at the top of the Snake section of your hw8.py
submission.
- More Snake (SOLO)
[30 pts]
Note: this game should run when the user presses '3' from the launch
screen.
This problem is SOLO.
Still in hw8.py, but starting from the code in the
snake8.py file at the end of the Snake Tutorial, add the following
features:
- A pause feature, where the game pauses when the player
presses 'p'
for 'pause', and where the game resumes (exactly where it left off) when
the user presses 'p' again. While paused, the board should be
visible, but the colors should be a bit dimmer than when unpaused.
- A score, which should be displayed at the top-center, above
the board (which will have to be moved down by enough pixels to make
room for the score). The score should start at 0 for each game,
and increase by 1 each time the snake eats food.
- A high score list, which should be displayed as part of the
"Game Over" screen at the end of each game. This is just a list of
the 3 highest scores (during this execution; so if you exit and restart
the program, the list is cleared), in sorted order from largest (on top)
to smallest (on the bottom). If there are fewer than 3 scores
available, do not list the missing scores as 0's, but just do not list
them at all (thus, you will list one score after the first game).
- Two levels. Level 1 works just as described in the
Snake tutorial. But when the snake eats the 3rd piece of food, the
game switches to Level 2, with the following changes:
- Speed-up: make the game move noticeably faster, but
not unplayably faster.
- Poison: in addition to randomly-placed food, a
separate randomly-placed piece of red poison is placed on the board
(and of course not on the snake nor on the food). If the snake
eats the poison, it dies. Note that you must be sure the
poison is not placed one square away from the snake's head unless
that is the only location remaining.
- Walls. When the game is paused, the user can click with
the mouse in empty cells to create walls (which are brown), or click on
walls to remove them. If the snake runs into a wall, it does not
die, but rather it destroys the wall at a cost of 1 point. If that
would result in a negative score, then the snake dies. At the end
of a level, if any walls existed for at least 20 moves on that level,
the score increases by 1 extra bonus point. Do not remove the
walls when placing new food or poison.
- Bonus: Line Runner (SOLO)
[up to 5 pts]
Note: this game should run when the user presses '4' from the launch
screen.
This problem is SOLO.
Line Runner is a simple, fun game available for Android and iPhones.
Find it, learn how it works, and then implement a game that is fairly close
to it (not exact, since it uses touch events, and maybe you should use
keyboard events seeing as your code will be running on a desktop and not a
phone). Don't go too crazy with this. Keep it simple (for
example, you can still get some points if the line runner is just, say, a
rectangle (though it'd be much more interesting if you attempt the running
animation)).. And
have fun!
carpe diem - carpe
diem - carpe diem - carpe diem - carpe diem
- carpe diem -
carpe diem - carpe diem - carpe diem