-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random blocks and key repeat #4
Conversation
Thanks for more another great contribution @mmssouza. I'll review this in soon carefully, but so far seems good points! |
@@ -107,6 +118,15 @@ Block const BLOCK_EMPTY = { | |||
{0, 0, 0}, | |||
}; | |||
|
|||
/*const Block *Blocks[] = { BLOCK_T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this variable?
static int counter = 1; | ||
switch (counter % 7) { | ||
case 0: | ||
current_block = rand() % BLOCK_NUM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and great!
main.c
Outdated
INT2F = 0; | ||
key = KEY_ROTATE; | ||
} | ||
seed[seed_idx] = val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice seed provider. Since the TM2 timer has been used as part of the seed, I think this will generate visually a sufficient random behavior for block generation.
The unique problem I saw is the first game after the microcontroller starts. If I undestand correctly, in this moment the seed will be always the same, right? Thus the first piece of a game started from scratch will always be the same.
After the first piece we will get a pseudo-random behavior which I think is good enough.
- key_management(): poll keys instead of using interrupts. Implemented key debounce and key repetition features. Check for left and right collisions prior block rotation. - fall_row_until() and check_game_over(): reimplemented for better performance. - game_manager(): case 1 in state machine modified. - interrupt code moved to stay after the main loop. - implemented a seeding and random block insersion strategy.
Dear Manoel,
This pull request implements both a strategy for random blocks insertion and the command repeat feature when keys are hold pressed.
Best regards,
Marcelo