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:
phillip committed 2026-09-03 22:27:22 +02:00
1 parent df9b859601
commit 0e7477031f
8 files changed
+96 -5

No files matched your search

+16
View File
@@ -100,6 +100,15 @@ void draw_apples_rotten(const GameState &state, const RenderAssets &assets, uint
}
}
void draw_apples_cursed(const GameState &state, const RenderAssets &assets, uint16_t &oamId) {
for (const std::array<int, 2> &apple : state.cursed_apples) {
oamSet(&oamSub, oamId, apple[0] * 8, apple[1] * 8, 0, 0, SpriteSize_8x8,
SpriteColorFormat_256Color, assets.gfx_apple_cursed, -1, false, false, false, false,
false);
oamId++;
}
}
} // namespace
void draw_game(const GameState &state, const RenderAssets &assets) {
@@ -108,6 +117,7 @@ void draw_game(const GameState &state, const RenderAssets &assets) {
if (!state.gameOver) {
draw_apples(state, assets, oamId);
draw_apples_rotten(state, assets, oamId);
draw_apples_cursed(state, assets, oamId);
draw_snake(state, assets, oamId);
return;
}
@@ -126,6 +136,12 @@ void draw_stats(const GameState &state, bool internals, bool musicEnabled, uint8
iprintf("\x1b[10;12HScore: %i", state.score);
if (state.curseTicksRemaining > 0) {
iprintf("\x1b[1;7HCONTROLS INVERTED!");
} else {
iprintf("\x1b[1;7H ");
}
if (!state.paused) {
return;
}