Skip to content

Commit

Permalink
fix tetris multiplayer attack bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ktpss95112 authored and john0312 committed Aug 17, 2024
1 parent 7997f9e commit 1d546f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fw/Core/Hitcon/App/TetrisApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void TetrisApp::OnEntry() {
// start a new game
game = hitcon::tetris::TetrisGame(tetris_random);
display_set_mode_scroll_text("Ready?");
if (multiplayer) {
game.game_register_attack_enemy_callback(SendAttackEnemyPacket);
}

// start the update task
hitcon::service::sched::scheduler.EnablePeriodic(&periodic_task);
Expand All @@ -58,9 +61,6 @@ void SetMultiplayer() { tetris_app.SetPlayerCount(MULTIPLAYER); }

void TetrisApp::SetPlayerCount(unsigned playerCount) {
multiplayer = (playerCount == MULTIPLAYER);
if (multiplayer) {
game.game_register_attack_enemy_callback(SendAttackEnemyPacket);
}
}

void TetrisApp::OnExit() {
Expand Down
2 changes: 1 addition & 1 deletion fw/Core/Hitcon/App/TetrisGame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void TetrisGame::clear_full_line() {
}

score += cleared_lines * CLEAR_LINE_SCORE;
if (attack_enemy_callback) {
if (attack_enemy_callback && cleared_lines > 0) {
attack_enemy_callback(cleared_lines);
}
}
Expand Down

0 comments on commit 1d546f2

Please sign in to comment.