Working on this Tetris project is so much fun. I pushed up my code to GitHub now that it is starting to take shape, you can find it here. Today mostly consisted of getting the block rotation working properly, updating block position as the game ticks, wall collisions, and saving fallen blocks to a separate state. I think the easiest way to handle this is for the "active" block to be tracked independently while all "fallen" blocks lose their metadata and are just placed in another matrix that is then overlaid on the grid.
This is working well so far, and also should make checking boundaries pretty
easy. The next step is ensuring falling blocks cannot collide with blocks that
have already fallen, and updating how to determine when a block should
transition from "active" to "fallen". My gut reaction for this is to add a
boolean like pending that toggles when we detect a given tick cannot make the
block fall any more. If the game ticks again and it pending and would trigger
pending again, then we move it to "fallen". The idea is to two fold;
I want to have a grace period for players to rotate the block before its set in stone, or for them to move it under other blocks
It allows this grace period expire and let the user slide the block to an open area where it can fall more.
This might end up giving the player too much grace, but we can just change which ticks do what; for instance every 10 ticks might move the block down, but only 6 ticks check the pending state. We can do this by disconnecting the falling ticks from the pending ticks. I most likely wont look at refactoring this until the game is actually playable though.
Outside of the bit of coding this evening, today ended up being very relaxing, past all the misc chores I got done. I've been reading the Red Rising series by Pierce Brown, and am really enjoying it. I'm on the 3rd book in the series and blowing through them. Albeit one of the first few books I've read since high school, I really cannot recommend this series enough if you enjoy sci-fi stuff.
