MAIN

EN

Volumetric tetris

Logical game • Experimental interface
22.01.2023

General educational game in the broad meaning of this word. In the process of learning programming languages, it is recommended to write your own version first and then use it for demonstrating and testing another software or hardware. The three-dimensional interface is written in JavaScript Canvas — the logic of the game itself is two-dimensional. Additional external libraries are not used.

Description of graphics algorithm: Spinning cube in space.

Experimental interface #

Turned off by default — you can just play Tetris. In addition to the two-dimensional version, two volumetric variants are added — parallel projection and perspective projection — parameters for each of them can be changed. For perspective projection: you can change the position of the observer screen and the remoteness of the projection source. The observer looks at the center of the image, and the center of the projection is remote at a distance, comparable to the size of the playing field. For parallel projection: you can change the vertical position. For both projections: you can rotate the playing field along all three axes. The central point for rotations — is the central lower far point of the field. For all variants of the image: the size of the cube — 32, the size of the square — 30 and the indent — 2. The origin of coordinates is located at the upper left point, the axes are directed: X to the right, Y downwards and Z to the distance.

Testing: start the game, collect a certain number of figures on the field, pause the game, and then switch the variants of the three-dimensional image, rotate the field with figures, change the transparency, move the central point and so on.

Controls: keyboard buttons with arrows — right, left, up, down and the button pause.

Level: , next level: , score:

Canvas for displaying computations results

Canvas for displaying computations results

Transparency of figures:
0%
Rotation of the playing field:
-1°
Vertical adjustment:
64
Center onto observer screen:
150
300
64
Remoteness of projection center:
640

Gaming process #

Game points are awarded for fully collected rows of the elements of the figures. The number of points scored depends on the number of rows collected, 10 points for each row if there are 10 cubes in a row, and multiply increases, if collected at the same time: 2 lines — by 3 times, 3 lines — by 5 times, 4 lines — by 10 times.

Game feature: the collected lines first blink and then disappear — meanwhile the gaming process is not suspended for this time — the current figure continues to fall.

Level increases when collecting 10 completed rows, that is 100 points, if there are 10 cubes in a row. At each new level, the speed of the figures increases and reaches a maximum at level 21. In snail mode, the speed increase becomes slower 5 times, and the speed of the figures reaches a maximum at level 104. The current speed is displayed above the playing field as a meter indicator.

© Golovin G.G., Code with comments, translation from Russian, 2023

Upward