--------------------------------------------- |[0, 0] [0, 1] [0, 2] ... [0, n] | |[1, 0] [1, 1] [1, 2] ... [1, n] | | | | . . | | . . | | . . | | | | | |[m, 0] [m, 1] [m, 2] ... [m, n] | ---------------------------------------------Where m is the number of rows: theGame.length - 1
nextShape and currentShape are blocks that are currently held by the game. nextShape is used
for the preview in the TetrisWindow.The final ints that follow are explained by the comments next to them.Don't worry too much about the RepaintThread or KeyHandler. Wait for 120 or take 160
to learn more about threads and threading, you'll learn about event handling next quarter.lvl is the current level that the game has advanced to.WAIT is a constant time that is divided every level you advance. 1000 is a wait time of 1
second before the block moves down again. 500 is a wait time of 1/2 sec before the block moves
down again.the public booleans are flags that are set by TetrisWindow to
denote either text mode or to turn on the debug messages. You can add
debug messages of your own by simply adding
if(debug) System.err.println(/*enter debug message here*/); anywhere in the codegameOver is a private boolean that denotes, you guessed it, game over.The main game is encapsulated in three methods:
initializeGame sets all of the variable necessary for the game to run without a hitch.
mainGame is the main body of the game, it's where the thread spends most of it's time. Your moveShapeDown, findLines, and moveRows are all called in this
When you die or kill the game by starting a new game in the middle of a game, cleanup game gets called