Add cursed apple: a status-effect apple that inverts controls
Eating a cursed apple inverts the snake's steering for CURSE_DURATION_TICKS ticks, shown on the top screen while active. The sprite is a recolored copy of the rotten-apple tile since all existing sprite tiles are already in use.
This commit is contained in:
1 parent
df9b859601
commit
0e7477031f
8 files changed
+96
-5
No files matched your search
@@ -30,23 +30,25 @@ bool handle_input_frame(InputContext &ctx) {
|
||||
}
|
||||
|
||||
if (!ctx.state->paused && !ctx.state->gameOver) {
|
||||
const bool cursed = ctx.state->curseTicksRemaining > 0;
|
||||
|
||||
if ((keys != 0U) && ((keys & KEY_UP) != 0U)) {
|
||||
ctx.state->snakeDirection = 0;
|
||||
ctx.state->snakeDirection = cursed ? 2 : 0;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
|
||||
if ((keys != 0U) && ((keys & KEY_RIGHT) != 0U)) {
|
||||
ctx.state->snakeDirection = 1;
|
||||
ctx.state->snakeDirection = cursed ? 3 : 1;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
|
||||
if ((keys != 0U) && ((keys & KEY_DOWN) != 0U)) {
|
||||
ctx.state->snakeDirection = 2;
|
||||
ctx.state->snakeDirection = cursed ? 0 : 2;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
|
||||
if ((keys != 0U) && ((keys & KEY_LEFT) != 0U)) {
|
||||
ctx.state->snakeDirection = 3;
|
||||
ctx.state->snakeDirection = cursed ? 1 : 3;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user