Skip to content

Commit

Permalink
feat: restart with attack button
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Mar 30, 2024
1 parent 2a63bfc commit 9468bc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion res/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<canvas id="gameCanvas" width="256" height="240" style="display: none"></canvas>
<canvas width="128" height="128"
style="display: none"
class="gpz-joy"
class="gpz-dpad"
data-gpz-bind="ArrowUp ArrowLeft ArrowDown ArrowRight">
</canvas>
<canvas width="128" height="128"
Expand Down
16 changes: 15 additions & 1 deletion src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ static unsigned char seed; /** randomness control **/
static unsigned char roosters_count; /** cocks counter **/
static unsigned char roosters_total; /** total of cocks arrive **/
static struct npc_ia_s npcs[MAX_ENIMIES];
static unsigned char holding; /** hold to restart battle **/

/** micromages 4 players **/
static unsigned char joysticks = 1; /** local multiplayer mode **/
Expand Down Expand Up @@ -770,6 +771,7 @@ void screen_celebration()
put_rank();
vram_adr(NTADR_A(31 - (joysticks * 4), 28));
put_score();
put_str(NTADR_A(1, 22), I18N_EN_RESTART_BTN);

/** print rank */
for (l = 0x7f, i = 0; i < joysticks; ++i)
Expand Down Expand Up @@ -851,6 +853,7 @@ void game_loop(void)
case FSM_DRAW_CELEBRATION:
screen_celebration();
gamestate = FSM_CELEBRATION;
holding = 0;
break;

case FSM_COUNT:
Expand Down Expand Up @@ -915,12 +918,23 @@ void game_loop(void)

case FSM_CELEBRATION:
seed = (seed + 1) % sizeof(good_seeds);
/** restart game (by start button) **/
if (gamepad_old[PLAYER_1] == 0) {
/** restart game **/
if ((gamepad[PLAYER_1] & PAD_START)) {
gamestate = FSM_RESTART;
}
}
/** restart game (by attack button) **/
if (holding > 60) {
gamestate = FSM_RESTART;
}
if (holding == 0 && (gamepad_old[PLAYER_1] & PAD_A) == 0 && gamepad[PLAYER_1] & PAD_A) {
holding = 1;
}
if (holding && gamepad[PLAYER_1] & PAD_A) {
++holding;
}
/** animate **/
s = 0;
i = winner_id;
++framecount.frames;
Expand Down

0 comments on commit 9468bc3

Please sign in to comment.