For example, type 1 blocks has 2 possible positions, while type 2 blocks has only 1 position and type 3 blocks has until 4 possible positions. So I decided to represent each block inside a 4x4 matrix of cells, as this:Įach block type has its own number of possible positions inside the 4x4 matrix. There are 7 different types of block, as seen on this table:Īs you can see, the biggest block is the red one (although in TetrisBox class you can customize the color of each block type), which is 4 cells wide (or high). I'm sure that can be other approaches to solve this problem, and even I'm sure many of them can be better than mine. Now I'm going to tell you what I've done about this. Really, the heavy work in this class is to control each falling block, its position inside the game board and to control the movements and rotations of each block. All the painting work is done every time that the board needs to be repainted: when the player moves the falling block or when the falling block drops because the time interval. When the game starts, the board is empty (all the cells are empty), but as well as the blocks are falling, the state of the cells may vary. The state of each cell is saved in memory using different structures. When a game is running, the control first paints its background (it can be a solid color, a gradient or a picture) and then it draws each cell. So, for example, a board with 20 rows, 10 columns and a CellSize of 25 will have a width of 241 pixels and a height of 481 pixels (that's because adjacent cells share the borders). The number of cells is defined by the Rows and Columns properties, and the size of each cell is defined by the CellSize property, which uses pixels.
Internally, the box represents the board game and is logical-divided into cells.
Falling blocks windows#
Because the PictureBox inheritance, it has a graphical UI and can be placed on any Windows Form or a user control. All the drawing work is done in the overwritten OnPaint method. The TetrisBox class inherits from the control, as it is basically a drawing surface. Once the work has been done, I'm proud because I think I've achieved all of my main goals. I wanted my TetrisBox class to be a size-customizable Falling Blocks game board, and to implement all the logic and drawing work to allow play Falling Blocks simply by setting a few property values and calling some simple methods. NET version, so this article presents to you the TetrisBox class: a VB.NET class extremely useful to create highly customizable Falling Blocks games in. Now I think the time has come to write a.
Falling blocks download#
You can still see the page (and download the ActiveX control and its source code) here.
Falling blocks software#
With that control I won some prize in the Planet Source Code monthly contest (some software pack, I don't remember well). In 2000, I developed a Tetris ActiveX control for the Planet Source Code site using Visual Basic 6.0. It rained some since then, but I still believe that Falling Blocks is one of the best videogames ever made. Many nights I saw the blocks falling every time I went to bed and closed my eyes.
There was a Falling Blocks gaming machine, and I spent hours and hours playing on it. When I was 18 I worked as DJ in a disco-pub at my hometown. Well, a long time ago, in a galaxy far far away, I was a highly-skilled Falling Blocks player.
The first place in the list is for the classic, extremely addictive Falling Blocks game. Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history.