The ways that you are generally expected to be making a Tetris-like game in are generally around the following:
- Store the field as a 2-dimensional array.
- If tools used do not support 2D arrays, store the field as a [cols * rows] long 1D array and prepare to face potential uncaught “index wrap” problems later on.
- Store the falling block as a similar (except smaller) 2D array. With the classic variant of tetris that’s a 4×4 array. You can also call it a “matrix” instead of “array” if that makes you feel cooler.
- Rotate the falling block by rotating the contents of the according array (more or less means circularly swapping the array cell values around). Also ensure that player cannot rotate a block in such way that it would get stuck in the wall or outer field edge.
- Calculate collisions between the falling block and field blocks by testing two arrays for overlaps. Note that X/Y “iterator” indexes have to be restricted accordingly to avoid misbehavior when the falling block is close to the map edge (thus it’s array bounds exceed beyond the edge by one or two blocks).
- Line clearing is done by checking if all cells are filled in any given row. If that is so, shift the contents of all rows above the filled line downwards (overwriting it), and add score bonus accordingly.
Indeed, that doesn’t sound too simple. At least not to someone new to programming.
So the question is – How to make the process not that?
- L Block
- J Block
- T Block
- S Block
- Z Block
- l Block
- Game Over
- Control – Maintains and displays the score
- Solid – Collision checking
- Block – Inherits Solid
- Falling Block – Different shaped block object parented to the falling object
So those will be my basic blocks ….
And these will be my logic for falling
And one room which is…
Well that’s it for today I suppose…?