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

Gameover bugfix #2

Merged
merged 2 commits into from
Mar 21, 2024
Merged

Gameover bugfix #2

merged 2 commits into from
Mar 21, 2024

Conversation

0xjmux
Copy link
Owner

@0xjmux 0xjmux commented Mar 21, 2024

should close #1

I think this fixes Issue #1; I was mistakenly updating the
highest_occupied_cell twice, once correctly in clear_rows() and then
once in the wrong direction in update_score(). Since it was updated
twice, it would never move down when rows were cleared - resulting in
the highest cell only climbing during gameplay, eventually reaching the
gameover condition.

#1
@0xjmux 0xjmux merged commit b0c2bc8 into main Mar 21, 2024
1 check passed
@0xjmux 0xjmux deleted the gameover_bugfix branch March 21, 2024 23:49
0xjmux added a commit that referenced this pull request Mar 23, 2024
* Fixed tg_update_score so it changes lines_cleared_last_level in right
  direction
* debugging prints peppered through problem code areas
* clear_rows modified so it won't try to move rows above the top of the
  board down, which is a possible cause of the premature crash as a
  result of garbage data I've been seeing (Issue #2). Garbage data ends up in the
  first few rows, pieces can't move down into it, they stop falling, and
  then the game_over condition activates.
    * to fix this, added another loop to clear_rows() so that it stops
      once it would start touching the top of the board, and will fill
      rows at the top with BG_COLOR without trying to read OOB
* lines_cleared_since_last_level static var that was a part of
  tg_update_score moved to TetrisGame struct for easier monitoring and
  testing; moving it makes replicating crash conditions in unit test
  suites much easier.
* print_board_state() function updated to take `bool ini_out` argument,
  which prepends boards printed to .ini files with the `;` comment
  character
* several new unit test cases added to `suite_1.c`, mostly for
  clear_rows() and relating functions.
* a couple new savegame .ini files added; some of these will likely be
  removed in the future, but they're very useful for replicating
  specific board conditions for testing.
* ini saving functionality moved to utils.c so it's all aggregated in
  the same place
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.

Premature gameover on line clear
1 participant