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

+36 -1
View File
@@ -71,6 +71,7 @@ void setup() {
renderAssets.gfx_head = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
renderAssets.gfx_apple = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
renderAssets.gfx_apple_rotten = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
renderAssets.gfx_apple_cursed = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
renderAssets.gfx_tail = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
dmaCopy(get_sprite_pointer(1), renderAssets.gfx_segment, 64);
@@ -80,10 +81,35 @@ void setup() {
dmaCopy(get_sprite_pointer(11), renderAssets.gfx_apple_rotten, 64);
consoleSelect(&topScreen);
dmaCopy(tilemapPal,SPRITE_PALETTE_SUB,tilemapPalLen);
// Recolor a copy of the rotten-apple tile (shadow/outline/fill/rot-spots) into unused
// palette slots to make the "cursed" apple sprite, since all 12 tiles are already in use.
const uint16_t CURSE_PAL_SHADOW = 14;
const uint16_t CURSE_PAL_OUTLINE = 15;
const uint16_t CURSE_PAL_FILL = 16;
const uint16_t CURSE_PAL_GLOW = 17;
SPRITE_PALETTE_SUB[CURSE_PAL_SHADOW] = RGB15(9, 5, 12);
SPRITE_PALETTE_SUB[CURSE_PAL_OUTLINE] = RGB15(10, 0, 14);
SPRITE_PALETTE_SUB[CURSE_PAL_FILL] = RGB15(18, 0, 22);
SPRITE_PALETTE_SUB[CURSE_PAL_GLOW] = RGB15(28, 0, 24);
const auto *rottenTilePixels = static_cast<const uint8_t *>(get_sprite_pointer(11));
uint8_t cursedTilePixels[64];
for (int i = 0; i < 64; i++) {
switch (rottenTilePixels[i]) {
case 5: cursedTilePixels[i] = static_cast<uint8_t>(CURSE_PAL_SHADOW); break;
case 7: cursedTilePixels[i] = static_cast<uint8_t>(CURSE_PAL_OUTLINE); break;
case 10: cursedTilePixels[i] = static_cast<uint8_t>(CURSE_PAL_FILL); break;
case 12: cursedTilePixels[i] = static_cast<uint8_t>(CURSE_PAL_GLOW); break;
default: cursedTilePixels[i] = rottenTilePixels[i]; break;
}
}
dmaCopy(cursedTilePixels, renderAssets.gfx_apple_cursed, 64);
audio_setup(audioContext);
}
@@ -115,8 +141,13 @@ void do_tick() {
if (check_collision_apples_rotten(gameState)) {
audio_play_boom(audioContext);
}
if (check_collision_apples_cursed(gameState)) {
audio_play_boom(audioContext);
}
spawn_apples(gameState);
spawn_apples_rotten(gameState);
spawn_apples_cursed(gameState);
tick_status_effects(gameState);
if (!wasGameOver && gameOver) {
audio_stop_music();
audio_play_fail(audioContext);
@@ -141,6 +172,8 @@ void init_game() {
snakeDirection = 1;
ticks = 0;
gameOver=false;
gameState.curseTicksRemaining = 0;
gameState.cursed_apples.clear();
consoleSelect(&topScreen);
consoleClear();
consoleSelect(&bottomScreen);
@@ -158,6 +191,8 @@ void init_game() {
snakeDirection = 1;
ticks = 0;
gameOver=false;
gameState.curseTicksRemaining = 0;
gameState.cursed_apples.clear();
consoleSelect(&topScreen);
consoleClear();
consoleSelect(&bottomScreen);