Tetris made on calculator. At first tried with JS canvas, but Casio BASIC language fitted me better, because I don't know JS really well, and I don't like it. The difficulty with this project, is that the processor is quite slow, so performing even few operations takes a lot of time. This is why the main challenge was optimizing the code as much as I could. Also I have experience with coding on a calculator, I made a snake last year.
No followers yet
Once you ship this you can't edit the description of the project, but you'll be able to add more devlogs and re-ship it as you add new features!
Added the detection of when shape is stuck at spawn, if it is, you automatically lose the game. Before that the only way to lose, to get the game over on top, was to hold period button.
This was final piece for Tetris on Casio fx-9750G.
Score is now displayed all the time and is dynamically changed as you fill the rows.
Also now when you press on period button the game ends.
The scoring is same as in original Tetris, so:
single - 40
double - 100
triple - 300
tetris - 1200
I found a nasty bug in my collision detection, I tried to fix it in different ways, and unfortunately I had to use matrix to store a field instead of 1 number. Also now when the row is full, it will be deleted. However the blocks above will not fall down yet.
I am running out of time to ship this project, so the matrix for field was necessary, but I will try to correct my method with 1 number and later fix the code.
The devlog is again sped up.
I added collision detection for shapes, and finally the game does not end when first shape hits the bottom. I store the whole field in a single number, my calculator supports numbers up to 9.999..*1099, so every state of block is a power of ten. Of course starting from 100.
YES this is very inefficient way to store field, however if I used matrix (which is also supported by my calculator) I would waste lot of memory, because each number in matrix uses 10 bytes of memory * 20 by 5 field = 1KB just for field to store 1 or 0. To put it into perspective, Tetris is my biggest program on calculator, and is expected to be around 1KB when finished. And my calculator has only 32KB, which is also used when plotting graphs, so I need to keep some of it free. Thus sacrificing speed over storage.
P.S. Devlog video is sped up to reduce the size of file and show the feature added.
The shapes now can be rotated both clockwise and counter clockwise. However if shape is close to the wall, and it's rotation would stick outside of game field, it will not be rotated at all.
The way I designed sprites loading made it very easy to perform rotation. Unfortunately I had to use extra 8 numbers in new List for temporary copy of shape before rotation, to revert the shape to it's pre rotation state if rotation is not allowed.
Added all the shapes and made the game select one shape at random. In image there are 3 of the 7 shapes.
I have added sprites, they can be maximum 5x5, which is more than enough for Tetris shapes. This sprite is also falling down and can be moved from side to side. I spent lot of time deciding how to implement them, because of my limited memory on calculator. This way they can be easily rotated in future.
Created a square that is falling down the field until it hits the bottom. Then the game ends.
I tried to make the web version work for another 2 hours, but I did not succeed. So I decided to refactor and make the project on my calculator. It is more stable and more consistent with output than JS I guess.
So now I made a procedure to create a field for Tetris, it is 5x20 cells.
Very impressed. Never going to pay attention in class after this