Different falling block based puzzle games have different forms of gravity.
Some allow for "chain reactions" or "recursive clears"; others don't.
Games that are played on a single plane viewed from overhead often don't need gravity. Games where the columns of the playfield are strict stacks (i.e. the only element that can be written to is the top one) don't need gravity.
Games without gravity include the following:
In a game with "row gravity", a completely empty row will slide toward the origin of the playfield.
This system cannot create a chain reaction unless it is applied both to rows and to columns.
The algorithm is simple: If blocks lie above an empty row, move everything above the empty row down one row.
Games with row gravity include the following:
In some games, every single square on the playfield is an independent unit and can fall independently.
Chain reactions run rampant; many games with this system have as their central goal to create an intricate chain reaction that buries the other player in garbage.
The algorithm is simple: For each column, if blocks lie above an empty space, move everything above the space down one space.
Repeat until nothing is falling anymore.
It can be thought of as row gravity that treats each column as a separate playfield.
Games with block gravity include the following:
Some games allow pieces to be arbitrarily shaped.
This is the most complicated form of gravity to implement in the general case.
(Insert algorithm description later. /msg me if you want me to hurry up and dig up my pseudocode.)
Games with piece gravity
- Tetris 2
- Quadra/Tetris Worlds Cascade
- The Next Tetris/Tetris Worlds Sticky (additionally, pieces of a given color cement together into one piece)
This is a special case of piece gravity that requires all game pieces to be rectangular.
It makes no difference if you treat a rectangular object as one object or as a set of slabs one row tall.
Thus, it becomes possible to use a row-by-row algorithm to compute what stops what.
Algorithm: For each row, from top to bottom, for each slab, if the space below the slab is empty, move the slab down one row.
Games with horizontal slab gravity include the following:
This is a special case of piece gravity that requires all pieces that touch one another to cement.
Again, it can be implemented with less state information than full piece gravity, using a flood fill.
Algorithm: Each block has one bit of state (true or false) representing whether it's floating. First set all empty spaces' floating state to false and all blocks' floating state to true, then flood-fill all blocks' floating state on the bottom row with false. In each frame, move all floating blocks down one space, then if any floating block rests on the bottom row or on a non-floating non-empty block, flood-fill that region's floating state with false.
Games with mass gravity include the following: