Quote:
Originally Posted by samurle
If I understand you, tetris blocks move in discrete amounts: e.g. move-stop-move-etc...
This type of stop-go motion is not what I'm trying to do.
The type of falling that I'm interested in is free-falling blocks. The block doesn't
stop falling until it hits something. 
|
Sorry, I was referring to dealing with the falling part, once you've dropped your block/removed blocks, and want the blocks above to fall down in the space created.
If you're talking about the smooth falling of the 3-block piece that the user controls, then that's easy. It's separate to the grid tilemap. It's just 3 sprites, you can treat that in pixels coords.
So.
State 1: "User controlling 3-block piece, or 4-block piece if this were tetris".
In this state, all of the settled blocks are just rendered as part of the standard gridded tile map, nothing special there.
The 3-block piece is rendered separately as a sprite overlay, in pixel resolution. It's subject to linear gravity (e.g. Y+=dY, where dY is your pixels/frame linear gravity).
Also when the user presses left or right, it is told to move Left say 32 pixels, or right 32 pixels respectively (which it'll do at a rate of X+=dX, this can either work linearly, or based on some ease-in/out etc. equation for effect).
As for collisions with the tilemap. You can create a tilemap solid testing function, something like this:
b1 TileMap::IsSolid(s32 x, s32 y)
{
if(x<0 || x>=COLS) return true;
if(y<0 || y>=ROWS) return true;
s32 tx = x / TILE_WIDTH;
s32 ty = y / TILE_HEIGHT;
return m_pTileMap[ty*COLS+tx] > 0;
}
You'd call the above numerous times to detect when how the perimeter of your 3-block piece interacts with the tile-map.
State 2:
Once your 3-block piece has come to rest for more than N Frames. Remove 3-block piece, and commit the values to the Tilemap, and evaluate how this affects the tilemap (i.e. if it causes blocks to disappear)
State 3:
Now any gaps need to be contracted (a method to do this, I described in my first post).
I'll see if I can do some drawings in photoshop to illustrate some of this. But there are many solutions for this. Some more elegant than others.