Extreme Tetris
My ninth grade self apparently categorize this version of Tetris as extreme; looking back at it now, it's simply the original Tetris game with extra weirdly shaped pieces and extra "cheating" moves I added. Before I went to the extreme, I programmed the original game first - screenshot below.
Even though it's just the original version of Tetris, I did include a lot of details. For example:
As I mentioned above, pieces do drop faster as you progress. This is controlled by the javax.swing.Timer class. At the start of the game, the timer delay is set to 500 milliseconds, and with every ten lines you complete, the delay gets reduced to 2/3 of the current delay. For example, with 10 lines complete, the delay is set to 500*2/3 ms, or 333ms. Then at 20 lines, the delay is set to 333*2/3 ms, or 222ms. This process continues indefinitely.
I think it's only fair that completing multiple lines at once grant you more points than completing the same amount of lines but one at a time. I had various different choices in trying to make the scoring intuitive; I could even assign random amount of points to each different number of lines completed at once. In the end, I chose to use the power of 3 as the basis. In my version of Tetris, the number of points you get for completing N number of lines is 3^(N-1) * 10:
- Pieces drop faster as you progress, similar to leveling up in the original game.
- The more lines you clear at once, the more points you get.
- A high score leaderboard.
- Pacman music and sound effects (I like the Pacman music better than Tetris music).
As I mentioned above, pieces do drop faster as you progress. This is controlled by the javax.swing.Timer class. At the start of the game, the timer delay is set to 500 milliseconds, and with every ten lines you complete, the delay gets reduced to 2/3 of the current delay. For example, with 10 lines complete, the delay is set to 500*2/3 ms, or 333ms. Then at 20 lines, the delay is set to 333*2/3 ms, or 222ms. This process continues indefinitely.
I think it's only fair that completing multiple lines at once grant you more points than completing the same amount of lines but one at a time. I had various different choices in trying to make the scoring intuitive; I could even assign random amount of points to each different number of lines completed at once. In the end, I chose to use the power of 3 as the basis. In my version of Tetris, the number of points you get for completing N number of lines is 3^(N-1) * 10:
You can see me adding points at line 313 and changing the delay (dropping speed) at line 316.
Next, I would like to talk about the high score leaderboard. It's generally straightforward except for the formatting of the text. I wanted to create a table-like chart that displays the names and scores smoothly lined up regardless of how long the name or how high/low the score is:
I thought adding spaces after the input name to a certain length, then printing the score would be enough to make everything aligned, turns out I was wrong! The default font used in a JDialog box is not equal width... Different names in the leaderboard would result in mis-aligned scores. I did eventually work around it though, as you can see above. (I won't go into detail as how I changed the font here. I'm sure there're tons of resources online that shows how.)
Music was easy to do. Just write a music player class and embedded it in the game. I will also not get into detail about this, because I'm sure there're tons of working music players out there for anyone to use.
I haven't talked about how I stored the pieces yet, because this is crucial to changing the normal Tetris to the crazy version. I used a simple coordinate system for the board and the pieces on the board:
Music was easy to do. Just write a music player class and embedded it in the game. I will also not get into detail about this, because I'm sure there're tons of working music players out there for anyone to use.
I haven't talked about how I stored the pieces yet, because this is crucial to changing the normal Tetris to the crazy version. I used a simple coordinate system for the board and the pieces on the board:
Above is the coordinate table for the different pieces for the normal Tetris. The first element represents an empty piece. To change the entire game and make it crazy, simply edit this table! You can even add coordinates and pieces to make pieces with 5 blocks, and they don't even need to be connected to be a "valid pieces". (You can see the first screenshot at the top of this page)
Here is an example of the coordinates table for a 5 blocks Tetris game:
Here is an example of the coordinates table for a 5 blocks Tetris game:
Screenshot:
To make the game complete, I had to implement rotations! That was not particularly difficult once you think about how coordinate points would rotate on a graph, and since my blocks are made based on coordinate points, easy task!
Lastly, since this 5-block-extreme-Tetris is way too hard to actually play in real life, I implemented a "mirrored flip" in addition to a rotation - A cheating move ;).
Last edit: 24 August, 2015.
Lastly, since this 5-block-extreme-Tetris is way too hard to actually play in real life, I implemented a "mirrored flip" in addition to a rotation - A cheating move ;).
Last edit: 24 August, 2015.