Computer Science 15-100 (APEA Section E), Summer 2008
Homework 7a
Due: Fri 1-Aug-2008 at 4:30pm (online submission and physical copy)
(no late submissions accepted).
Note: This assignment extends the Tetris programs that you wrote for
hw6. While you will only be graded on the new portions assigned here, you
must start from your own Tetris program from that assignment. If you did
not complete that assignment, you must first complete that assignment prior to
working on this assignment (even if it is too late to obtain a grade for that
work)!
Also note: some of these questions may be underspecified. For example, for question #1, what should happen to a falling piece if it collides upon rotating the board? For all such issues, you should identify them and make reasonable assumptions about how to handle them. Place a comment in the header of your solution file listing these issues and your solutions to them.
Board Rotation
Modify your Tetris program so that shift-UP, rather than rotating the
falling piece, rotates the ENTIRE BOARD 90 degrees clockwise (rotated
about the middle of the board, not the top-left corner), so that the old
left edge is now the top and the old top is now the right edge. When
doing this, to keep the game playable, set all values in the first 3
rows of the new, rotated board to empty, to allow new falling pieces to
at least enter the board. Also, subtract some reasonable amount from
the score as the price for doing this. Finally, for some small bonus,
adjust your window size afterwards to fit the new board (again, that’s
bonus – if you do not do the bonus, just set your window size to be
large enough to accommodate the board in any rotated configuration).
Custom Pieces
Modify your Tetris
program to include a piece with a “hole” in the middle, along with 3
other more “advanced” pieces of your choosing. If you had levels (as
some of you do), you could introduce these pieces into your game as the
user advances to harder levels.
Preview Next Piece
Modify your Tetris
program to include a “next piece preview” which displays what the NEXT
piece will be (this is often displayed to the right of the board). If
you think about this, you can reuse your paintPiece method, but you’ll
have to supply the piece to paint (whether it is the current piece or
the next piece), and for the next piece, you might supply a column that
is actually off the right edge of the board (think about it).
Bonus: Custom Piece Editor
Add a simple editor of your own design that allows the user to
create their own custom piece shapes. Provide a file,
pieceShapes.txt, that stores these definitions in some reasonably
human-readable format. Have your Tetris game read this file and
use the shapes in that file, or if no such file exists, to first save
the default pieces to that file (in the appropriate format, of course)
and then use the file.
Carpe diem!