Turnin will be disabled after 11:59 pm on Sunday 3/5/2006. Programs submitted before 11:59 pm on Thursday 3/2/2006 will receive 10% extra credit. Programs submitted before 11:59 pm on Tuesday 2/28/2006 will received 20% extra credit.
For this project, you are to write a Java application to play Tetris. A discussion of Tetris can be found at http://en.wikipedia.org/wiki/Tetris. Tetris is a real time game that continuously drops pieces (called Tetrominoes) on to a pile. The user is allowed to rotate and move these pieces left and/or right to fill up rows in the pile. When a row is completely filled, that row disappears and all pieces on top of that row fall down. Over time, the tetrominoes fall faster and the game is over when the pile reaches to the top of the playing area.
There are 7 different Tetrominoes. Each one is made up of 4 blocks. The 7 Tetrominoes are referred to as I, T, O, L, J, S and Z. These seven Tetrominoes are shown below:
The playing area is a grid of 20 rows and 10 columns. When a tetromino is dropped, it is added to the playing area at the top most row and will descend until it cannot go any farther down. The descent rate is controlled by a timer. Every time the timer "goes off", the tetromino will move down one row. This will continue until the time when the timer goes off and the tetromino can't go to the next row because it is either at the bottom row or it is on top of another tetromino. At this time, the tetromino will become locked in place and a new tetromino will be dropped. When the timer first places a tetromino on the bottom row or on top of another tetromino, the tetromino may be moved left or right (assuming there is room of it to move) or maybe even be able to rotate. Your program should randomly select the next tetromino from all seven different kinds.
At every 20th tetromino is dropped, the speed of the descent should increase. This means that you should shorten the timer's delay interval. The exact time of the delay interval will be left up to the programmer. You may wish to start with a value between a half second to a second and increase the speed by about a .02th of a second after every 20 tetrominoes.
Your program will need controls to move the tetromino left or right, rotate it left or right, drop the tetromino and pause the game. These controls are to respond to keyboard presses. Examples of key event programs can be found on the Java Example Page. These controls must not need any modifier keys (such as Shift, Control, Alt) to invoke the control. The exact keys used will be left to the programmer. You are also to add buttons that could activate these controls.
A few notes on the movements of the tetromino.
In addition to the playing area and the control buttons, your program is to display the following information
A player's score is increased everytime a row is filled in and cleared. If a player fills in and clears multiple lines simultaneously, the more point are scored. The point values are as follows:
Your program will need a menu that will perform the following operations.
This menu button is in addition the quitting your program by clicking on the X on the right side of the title bar.
The About box can be a simple dialog box that gives the name of the program's author, when the program was written and why ("The X-th programming assignment for CS 340").
This can be a dialog box that describes the basics of your program. This should include a description of all menu, button and keyboard operations.
This should clear any remnents of a previous game and begin play on a new game. You may wish to include a button and keyboard press to perform this function.
The playing area could be make of a a grid of 20x10 labels. I have (at least) two images. One image to show an empty position in the grid. The other image to show an occuppied position in the grid. A position may be occupped by the current falling tetromino or was part of a previously fallen tetromino. As the current tetromino falls, moves, rotates, etc., the images contained in the labels in the grid change to reflect the falling, moving, rotating tetromino. Each tetromino will take up 4 different positions in the grid. Here are some program that I was using to mess around with this idea.
That uses these image files. Here are a list of images that could be used for this program.Another was is similar to the previous idea, but to draw in a JPanel instead of using JLabels and images. This idea doesn't use images, but requires that the programmer keep track of the coordinate positions of pixels on the screen and to draw/redraw the pixels when needed.
However for 10 pts extra credit, you can implement both forms of gravity and have a menu option that allows the user to switch between the two forms of gravity.
Turnin your program electronically using the "turnin" command from your CS account as follows:
turnin -c cs340 -p mp3 [your project directory]
where the [your project directory] is the directory name under which you have
all your files related to this programming problem. The turnin command will
automatically compress the data under your directory, so there is no need to do
the compression by yourself.
Notice you can only invoke turnin command on the Linux machines in the lab or after logging into the server machine oscar.cs.uic.edu.
If you want to verify that your project was turned in, look in the turnin directory for a file with your userid. For instance for this project, from your CS account you would type:
turnin -c cs340 -p mp3 -v
Note that you can execute turnin as many times as you would like, up until the program deadline when turnin will be disabled for this project. Each time you execute turnin for a project, you overwrite all of what you had turned in previously for that project. It does not work in an incremental way.