-
Notifications
You must be signed in to change notification settings - Fork 17
spaceship use bitmap #429
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
base: main
Are you sure you want to change the base?
spaceship use bitmap #429
Conversation
011860a to
955aad7
Compare
955aad7 to
cf00590
Compare
fw/Core/Hitcon/App/SpaceshipApp.cc
Outdated
| if (_routine_task.IsEnabled()) { | ||
| scheduler.DisablePeriodic(&_routine_task); | ||
| } | ||
| scheduler.DisablePeriodic(&_routine_task); |
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 are you removing the check here? You're certain it won't happen? Note that disabling an already disabled periodic task will assert.
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.
Let me restore it.
| namespace spaceship { | ||
|
|
||
| enum state_t { INIT, RUN, GAME_OVER, END }; | ||
|
|
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.
You might want to static_assert() on the display height.
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.
Can I use
static constexpr unsigned PLANE_UPPER_BOUND = 1 << (DISPLAY_HEIGHT-2);
instead of using
static_assert(DISPLAY_HEIGHT==8)
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.
The reason why you need static_assert() is because you used a byte to represent a column, which is 8 pixels currently. Whenever that changes your code will break, and we'll want to warn anyone of that using static_assert().
fw/Core/Hitcon/App/SpaceshipApp.cc
Outdated
| for (uint8_t i = 0; i < 4; i++) { | ||
| if (_my_plane[i] == _enemy_position) { | ||
| for (uint8_t i = 0; i < 2; i++) { | ||
| if ((_my_plane[i] & _enemy_position[i]) > 0) { |
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.
Usually we do != 0 to avoid signedness shenanigans
| for (uint8_t i = 0; i < (DISPLAY_WIDTH - 1); i++) { | ||
| _enemy_position[i] = _enemy_position[i + 1]; | ||
| _enemy_position[i + 1] = 0; | ||
| if (_enemy_position[i] > 0) { |
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.
nit: Best to use != 0 for bitfield checks
Purpose
Reduce memory usage from
DISPLAY_WIDTH x DISPLAY_HEIGHT x uint8_ttoDISPLAY_WIDTH x uint8_t.