Please sign in to access this page
June 17, 2025
Maybe make rotation more linear with speed :D
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.
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.
Shipwright gave you feedback
This looks awesome! Really good job, maybe add a feature where the user can adjust the resolution of the simulation.
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.
Fixed error when closing the window with the 'X'. Also compiled the exe file and published it on github.
Updated readme
Added 2 new blocks, lava and stone. In contact with water, lava converts into stone. Stone does not fall. Both of them can be dissolved by acid.
Also added slider for diameter of creation blocks at cursor.
Added acid to the game, it dissolves everything except air and itself. While creating it, I refactored some of the code to make it more readable.
Made sand falling down through water, it turned out to be more complex than I first thought.
Added functionality to water block, now it flows and spills.
Created a menu to select which block to create on canvas. Now the pixel window has an internal variable that tracks which block is currently selected to be drawn, when you choose from the menu, it changes. Otherwise no more blocks or block functionality added.
I have created an enum for block types, due to that I also had to correct the code to accept the enum instead of the integer. As next I have added colors to the blocks, and added 3 blocks in total: sand, wall and water. Currently only sand and wall blocks have implemented functionality. Sand logic is the logic from previous devlogs, and the wall is just standing still.
Added new rule for falling, to the pixels, now when they are on some other pixel, they will fall diagonally down either to the right or to the left, if there is free spot.
The pixel now have only 1 rule for falling, that is when it is free beneath them, they will fall. You can create more pixels by dragging with left mouse button pressed.
Created a pixel window class, which resizes based on number of rows, columns and pixel size.
A sandspiel copy (I did not know that sandspiel existed when I started this project) made in python tkinter. It includes some basic mechanics of different blocks falling down; water, lava and acid spilling. Wall being as immovable obstacle and simple sinking of sand in water and water forming stone in contact with lava. It also includes few different sizes for creation of blocks. I coded without AI and did not generate anything with it.
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.
Created new program that will create a table either as output to console or write to the file. You need to provide space separated data for columns, and new line character separated rows. Right now it can read a file, store its contents into matrix of values, and calculate minimal width for each column, so data can fit in.
Menu program now scans current directory it is in and adds all executables into menu to be selected. When program is selected and enter is pressed, the executable is run, after it finishes, it returns you back to the menu. You can exit it by pressing 'q'. In video I run tree.exe file, which is previous program I made.
Now when the tree program is run, it prompts for path to the directory you want to make tree out of. If path is invalid, or you enter '' or '.', then it defaults to the current directory the program is in. Otherwise, you can just specify folder or path relative to the current directory, like, when you are in c:\users you can just type your username and it will select c:\users\username. Or you can also specify full path.
Now directory structure can give name of folder or file inside it using getNext method. Using that the program now can display names of all files and folders, also the ones that are nested in the folders of current directory. The image shows the contents of my directory in this project.
In readme there is a way to install it with scoop package manager. Project comes with 3 files: xmenu.exe is a menu selector for all .exe files in directory. You navigate using up and down Vim motions, so j for down and k for up. To select file press enter, and to exit menu press q or Q. Also it is only windows dependent file. tree.exe creates a tree of specified directory including files. table.exe creates a table from data that is output into specified file, or console if no file is provided.
Added default objects: all 8 planets, Sun and Moon.
add images in readme, make some default objects to directly use like sun earth moon also the collisions are not from the surface right now seems like they are with the COM try fixing that too
Tested different ways to render objects on canvas, and stick with the one that worked the best. Also in readme in repository added tutorial to compile python file into executable. And removed those 4 static objects from simulation.
Added help button.
Added modification of already placed object, now if already placed object is clicked, the menu will pop up and show that info about it. Also added option to change center in pop up menu. And lastly, now it is possible to copy selected objects by pressing c key.
Added info menu in top right corner of canvas. It displays the scale of simulation, and if it is running or paused.
I split the code into different files, also removed simulation toggle button and binded space bar to toggle simulation.
Added dynamic addition of bodies. When canvas is left clicked, new body is 'created' and its attributes can be changed, to see change to take action you need to press Enter key, and to create the body, so it will be simulated along with other bodies, you need to press left Alt. Also by pressing right mouse button you can delete the previewed body. Following attributes can be changed: mass, radius, color, x component of velocity vector, y component of velocity vector.
Added start / pause button under the canvas. Also changed background to black.
Added gravitation pull between objects. Also encountered bug with tags in tkinter canvas, and spent around hour fixing it. Currently you can add objects only from code statically, not by clicking mouse.
Now I am able to add objects into the game, they are simple structures with mass, radius, color, center and velocity data members. Velocity is not implemented yet. And radius and center of object have to be scaled by 1e10, because that is default scale of the game, this is done for better accuracy.
Set up game screen and basic game loop alongside with option to leave by pressing Esc key.
Simulates simple gravity of objects floating in space. Whole program is written in python tkinter. It supports dynamic addition, deletion and modification of bodies, also with copying them. PS. the recorded time is quite high, because I spent a lot of time testing and correcting different errors, because I wanted to make it without AI.
Added buttons to clear the text in entry, another one to reset counter of key presses and last one that toggles the heatmap of all key presses.
Now when buttons are pressed you can see how the gradient slowly changes from green to orange and then back to normal.
Added text field for typing, and added letters onto keys.
Created keyboard layout, on which will be colored with their respective color.
This app shows which keys you pressed the most while typing. The lack of CSS is intentional, because simplicity is something to admire.
I am trying to encode message now, I was successful in that, however I noticed that I am most probably writing into MSB of pixel channel instead of LSB, which creates this kinda cool pattern on resulting image. I always write into red channel when working with RGB and RGBA images, that's why you can see red, cyan and green. They are created when you take out the red from original color under them.
Finally the program is able to successfully open, store and save data from one image into new copy. The issue with filtering was that when you reconstruct data from filtered into raw (decode) you also use raw bytes of data for predictors, same as when filtering from raw (encoding). So when you encode you always read the input stream for raw bytes, but when you decode you have to read from decoded stream to get the raw data for predictors. I was very confused from the png documentation and spent much time on this simple thing. As seen from devlog image the original and copy of image are the same.
I have been able to open the png file, save all data from, decompress and compress it again and write back to the new file. Except the filtering of data. It has to be fixed, because there is some error, which causes image corruption. If I comment out the filtering out and filtering in, in the file, it saves as normal. On the devlog image there is original image (left) and saved image using corrupt filtering function (right).
Now program is also able to filter the decompressed data back into the original data. Also it is bale to compress the data back.
Now I can decompress the data from IDAT chunks. I used zlib library and inflate algorithm. I had to install it and link it, this is where I spent much time, because I did not know that.
Now I am able to display all the contents of all IDAT chunks, I had problem where I was pushing pointer that was changing, into vector, because of that it was not displaying correct data. I created Image class, which takes char pointer and size of it, copies it and only after that pushes it into vector. It solved the issue.
Refined the code even more.
Added executable file, that does not open terminal, only GUI. Also added docstring to the functions in code for better understanding.
Now I am able to display all names and lengths of chunks in png.
This is console program, in which you can encode and decode messages from png images.
Cleaned up the code and added few comments on key places
Finally sides along all 3 axis can be rotated. And also I implemented new system of knowing which direction to rotate each side. Now only the only thing is left to do, is to optimize it and remove commented code.
Now the rotation of side of cube around y-axis is finished in any orientation of the cube without breaking the whole thing.
Now I can rotate the side around x-axis in any rotation of the whole cube without it breaking.
I have made the big cube out of 27 smaller ones. Now only the rotation around x-axis works, but only if whole cube has been rotated only around x-axis. If I rotate whole cube around not x-axis, it becomes messed up, as shown in the end of video. Also in video the movement of rotation of whole cube is uneven, but it is quite smooth on screen.
As next I decided to add faces to the cube, I have read that it is done through triangles, so I added 12 triangles in total. However I had not included the functionality of drawing only the faces I see, instead drawing all of them, so some faces were drawn on the top of others, and some were drawn below all the other. At right angle this created a funny illusion of it spinning right and left, even tough it was only spinning right.
In this project I wanted to learn how to render 3D objects without using any special libraries. Only tkinter and it's canvas with 2D drawing, first I had to learn about projection of points onto the screen. Together with that I decided to add rotation to the cube, so I can see if it is projecting correctly. In the end I got this result.
GUI Rubik's cube made in python with tkinter. Main goal of this project was to learn more about 3D rendering, especially I wanted to understand all of math behind it, and also I like Rubik's cubes. First 4 devlogs were not made in the same time as the features added, I simply forgot to do them but still decided to add them, to track progress of my learning in this field.
This was widely regarded as a great move by everyone.