Skip to content
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

Merged
merged 4 commits into from
Mar 10, 2019
Merged

Random blocks and key repeat #4

merged 4 commits into from
Mar 10, 2019

Conversation

mmssouza
Copy link
Contributor

@mmssouza mmssouza commented Dec 16, 2018

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

@ryukinix
Copy link
Owner

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,
Copy link
Owner

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;
Copy link
Owner

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;
Copy link
Owner

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.

mmssouza and others added 2 commits March 10, 2019 18:56
- 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.
@ryukinix
Copy link
Owner

I'm taking this changes to work on the task of #6. Thanks for all awesome contribs @mmssouza !!!

@ryukinix ryukinix merged commit 9e4b756 into ryukinix:master Mar 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants