Tetris 1984
- JavaScript
- ASCII Game
- Old School
0 Comments

Table of contents
Background
Tetris is a very well known game that has existed for ages! It could seem..
If you don’t know what Tetris is, then I feel sorry for you… Basically, you’re supposed to stack these so called tetrominos and clear lines to get the best score possible.
Tetris has been one of my favourite games for a very long time. I’ve always been interested in learning new techniques like ST-stacking for maximizing the score instead of just making perfect stacks all the time. After countless hours of playing Tetris, I decided that I would create my own Tetris clone in java, I had just started out with learning java at the time. The result can be seen to the right. However, there we’re lots of problems with my first version of the game:
- It performed very poorly.
- I had around 400 lines of if-statements for collision detection, unique for each block, which means 2800 lines of if-statements. No wonder the performance was bad. And after all that, the collision didn’t even work properly (what a surprise).
- It used tons of images that were different for every piece, with and without colour (not sure why I did that).
Overall, the game felt a bit weird to play since it didn’t really work, so I put it aside for the time being.
Javascript?!
Time went by and I had learned a lot more programming. I now knew about this cool thing called Javascript! So I decided that I would give Tetris another try, and the result of that can be seen to the left. There were a lot of improvements in this version. The entire thing consisted of around 300 lines of code and I used only 1 single square image. I also had a working bag now, which you can read about under “The Game”. Things we’re looking good and I was kind of proud of it. The collision still wasn’t perfect, but I decided to leave it as it was.
Reminder
One day while I was looking through my feed, I saw a throw back post to the Tetris 1984 version and instantly thought, “I have to recreate this!”. So that’s when I decided to make yet another Tetris game!
The Game: Tetris
Tetris is a fun grid based game where you stack tetrominos and clear lines to get score. The tetrominos come in 7 different shapes which are usually referred to as I, J, L, S, Z, T, O
, the names come from their shapes.
Rules
Tetris is normally played on a 10x20 matrix where each piece, or tetromino, is built out of 4 smaller square cells. The objective is to clear lines and gain the highest score. If you clear multiple lines at the same time you’ll get extra score, and if you clear 4 lines you get a TETRIS! But if your stack reaches the top of the screen, then it’s GAME OVER.
The game is pretty simple which makes it easy for a beginner to start playing but it’s very hard to master since every game is unique. Which brings us to the bag.
The Bag
The bag holds all the 7 unique pieces. Each piece that you get during gameplay is randomly picked out of the bag, when the bag is empty the game just fills it up with 7 new unique pieces, it’s a simple concept. What this means is that it’s impossible for 3 consecutive pieces to be of the same shape. Looking back at my first tetris game, that could sometimes happen, and it made it a bit less fun to play.
My Tetris 1984 version
My version of the game is kind of a mix between the original 1984 version and some modern day versions. The main thing about my version that is like the 1984 version is the style. I even added a button in the bottom-right corner that toggles a filter which makes it look like an old screen. Gameplay wise, the pieces lock into place on contact and you can’t hold pieces, just like in the old days. It also doesn’t support spinning pieces into place like many of the modern versions do, nor does it show ghostpieces. However, the input method that I use is more similar to the modern versions of the game.
Game Modes
As I said, I’ve played tetris for a very long time, and one thing that I’ve always wanted to do is to break the fixed 10x20 matrix. I decided that I would use different dimensions and see how they affected the gameplay. I ended up making 2 new game modes: King Size and Claustrophobia.
King Size
This game mode is played on a 15x20 matrix.
What I noticed from playing this game mode is that you have to be patient since there are now 300 cells instead of 200 which makes the game A LOT longer. You also have to be good at keeping a clean stack since it’ll take longer to clean up mistakes. But at the same time, keeping a clean stack becomes easier since there is so much room for error.
So if you’re not really that skilled but have a lot of time, this could be something fun to play around with.
Claustrophobia
This game mode is played on a 5x20 matrix and it’s really interesting.
I first tried a 4x20 matrix which is the smallest possible, since the I
piece can be 4 cells wide, but I found that there wasn’t enough room to really do anything special.
Also, you could always clear a line by placing the I
piece horizontally.
That’s why I decided to go with a 5x20 matrix.
What I found out about this game mode was that it is very high paced and you have to make quick decisions since there isn’t any room for error at all. One thing you have to keep track of is the upcoming piece, and try to plan ahead to play the safest or best move.
After a while of playing this, it really does make you feel claustrophobic.
Extra
Also, if anyone wants to go crazy and experiment, I made it so that you can set the matrix size through a simple query by adding ?x=a&y=b
to the link where a and b
are the dimensions you want.