feat: add temporary hazardous barriers in hard mode

This commit is contained in:
phillip committed 2026-10-03 21:32:02 +02:00
1 parent 08a4b41280
commit 9a3a0bd9fd
8 files changed
+466 -17

No files matched your search

+58 -5
View File
@@ -85,6 +85,8 @@ void setup() {
renderAssets.gfx_tail_v[1] = 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_barrier = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
renderAssets.gfx_barrier_warn = oamAllocateGfx(&oamSub, SpriteSize_8x8, SpriteColorFormat_256Color);
dmaCopy(get_sprite_pointer(1), renderAssets.gfx_segment, 64);
dmaCopy(get_sprite_pointer(2), renderAssets.gfx_segment_small, 64);
@@ -109,6 +111,12 @@ void setup() {
SPRITE_PALETTE_SUB[CURSE_PAL_CORE] = RGB15(31, 26, 31); // Glowing White-Pink Core
SPRITE_PALETTE_SUB[CURSE_PAL_LEAF] = RGB15(2, 31, 10); // Toxic Radioactive Neon Green
// Setup initial colors for the hard-mode temporary fatal barriers
SPRITE_PALETTE_SUB[BARRIER_PAL_EDGE] = RGB15(12, 0, 3);
SPRITE_PALETTE_SUB[BARRIER_PAL_FILL] = RGB15(22, 2, 4);
SPRITE_PALETTE_SUB[BARRIER_PAL_STRIPE] = RGB15(31, 22, 6);
SPRITE_PALETTE_SUB[BARRIER_PAL_WARN] = RGB15(18, 4, 2);
// 8x8 256-color tile data for Cursed Apple (vibrant electric purple apple with radioactive green horn & glowing core)
static const uint32_t CURSED_APPLE_TILE[16] = {
0x10000000, 0x00001414,
@@ -121,11 +129,47 @@ void setup() {
0x10100000, 0x00101000,
};
// 8x8 256-color tile data for solid fatal barrier (bordered hazard stripe block)
static const uint32_t BARRIER_SOLID_TILE[16] = {
0x15151515, 0x15151515,
0x16171715, 0x15171716,
0x16161715, 0x15161717,
0x17161615, 0x15161617,
0x17171615, 0x15171616,
0x16171715, 0x15171716,
0x16161715, 0x15161717,
0x15151515, 0x15151515,
};
// 8x8 256-color tile data for barrier warning announcement (pulsing reticle frame)
static const uint32_t BARRIER_WARN_TILE[16] = {
0x00001818, 0x18180000,
0x18000018, 0x18000018,
0x18180000, 0x00001818,
0x00181800, 0x00181800,
0x00181800, 0x00181800,
0x18180000, 0x00001818,
0x18000018, 0x18000018,
0x00001818, 0x18180000,
};
// Copy cursed apple tile directly into allocated VRAM (32 halfwords)
auto *destAppleCursed = static_cast<uint16_t *>(renderAssets.gfx_apple_cursed);
const auto *srcAppleCursed = reinterpret_cast<const uint16_t *>(CURSED_APPLE_TILE);
auto *dest_apple_cursed = static_cast<uint16_t *>(renderAssets.gfx_apple_cursed);
const auto *src_apple_cursed = reinterpret_cast<const uint16_t *>(CURSED_APPLE_TILE);
for (size_t i = 0; i < 32; i++) {
destAppleCursed[i] = srcAppleCursed[i];
dest_apple_cursed[i] = src_apple_cursed[i];
}
auto *dest_barrier = static_cast<uint16_t *>(renderAssets.gfx_barrier);
const auto *src_barrier = reinterpret_cast<const uint16_t *>(BARRIER_SOLID_TILE);
for (size_t i = 0; i < 32; i++) {
dest_barrier[i] = src_barrier[i];
}
auto *dest_barrier_warn = static_cast<uint16_t *>(renderAssets.gfx_barrier_warn);
const auto *src_barrier_warn = reinterpret_cast<const uint16_t *>(BARRIER_WARN_TILE);
for (size_t i = 0; i < 32; i++) {
dest_barrier_warn[i] = src_barrier_warn[i];
}
audio_setup(audioContext);
@@ -137,6 +181,10 @@ void handle_vblank() {
if (gameState.scene == Scene::Playing) {
consoleSelect(&topScreen);
draw_stats(gameState, renderAssets, internals, audio_is_music_enabled(audioContext), frame);
if (!gameState.paused) {
tick_barriers_frame(gameState);
}
draw_barriers(gameState, renderAssets, frame);
}
// Dynamic pulsing radioactive glow for Cursed Apples (smooth 60fps breathing)
@@ -157,7 +205,7 @@ void do_tick() {
if (gameState.scene == Scene::Playing && !paused) {
ticks++;
if (!gameOver){
const bool wasGameOver = gameOver;
const bool was_game_over = gameOver;
/*if (hardMode) {
timerStop(0);
@@ -167,6 +215,9 @@ void do_tick() {
update_snake(gameState);
audio_play_plop(audioContext);
check_collision_self(gameState);
if (check_collision_barriers(gameState)) {
audio_play_boom(audioContext);
}
if (check_collision_apples(gameState)) {
audio_play_pickup(audioContext);
bg_trigger_pulse(bgContext);
@@ -181,8 +232,9 @@ void do_tick() {
spawn_apples(gameState);
spawn_apples_rotten(gameState);
spawn_apples_cursed(gameState);
spawn_barriers(gameState);
tick_status_effects(gameState);
if (!wasGameOver && gameOver) {
if (!was_game_over && gameOver) {
audio_stop_music();
audio_play_fail(audioContext);
}
@@ -194,6 +246,7 @@ void do_tick() {
void init_game() {
applesEaten = 0;
reset_barriers(gameState);
if (hardMode) {
timerStart(0, ClockDivider_1024, calculate_timer_reload(gameState), do_tick);
setBackdropColorSub(RGB15(8, 3, 3));