feat: add custom background rendering and speed scaling features for snake gameplay

This commit is contained in:
phillip committed 2026-10-03 20:58:33 +02:00
1 parent 93c0a44027
commit 60bf111400
13 files changed
+711 -26

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#ifndef GAME_BG_H
#define GAME_BG_H
#include <nds.h>
#include "game_state.h"
struct BackgroundContext {
int bg_main_id = -1;
int bg_sub_id = -1;
// Fixed-point (8.8) scroll accumulators for smooth 60fps drift
uint16_t scroll_main_x_fp = 0;
uint16_t scroll_main_y_fp = 0;
uint16_t scroll_sub_x_fp = 0;
uint16_t scroll_sub_y_fp = 0;
// Animation frame counter & timers
uint8_t anim_phase = 0;
uint16_t anim_phase_fp = 0; // Fixed-point (8.8) phase accumulator
uint8_t pulse_timer = 0; // Triggered when an apple is eaten
// Cached state to optimize updates
bool hard_mode = false;
bool is_cursed = false;
bool game_over = false;
Scene scene = Scene::Menu;
};
void bg_setup(BackgroundContext &bg_ctx, int top_console_bg_id, int bottom_console_bg_id);
void bg_update(BackgroundContext &bg_ctx, const GameState &state, uint8_t frame);
void bg_trigger_pulse(BackgroundContext &bg_ctx);
void bg_set_scene(BackgroundContext &bg_ctx, Scene scene, bool hard_mode);
#endif // GAME_BG_H