feat: add temporary hazardous barriers in hard mode
This commit is contained in:
1 parent
08a4b41280
commit
9a3a0bd9fd
8 files changed
+466
-17
No files matched your search
@@ -6,6 +6,8 @@
|
||||
#include <vector>
|
||||
#include <nds/ndstypes.h>
|
||||
|
||||
#include "consts.h"
|
||||
|
||||
enum class Scene {
|
||||
Menu,
|
||||
Playing,
|
||||
@@ -13,6 +15,23 @@ enum class Scene {
|
||||
|
||||
constexpr int MENU_ITEM_COUNT = 3;
|
||||
|
||||
enum class BarrierPhase : uint8_t {
|
||||
Inactive, // Slot free
|
||||
Warning, // Flashing announcement, harmless
|
||||
Active, // Solid and fatal to the snake head
|
||||
};
|
||||
|
||||
// Temporary hard-mode wall: a straight line of `length` cells starting at (x, y).
|
||||
// Lifetime is tracked in VBlank frames (see tick_barriers_frame()).
|
||||
struct Barrier {
|
||||
BarrierPhase phase = BarrierPhase::Inactive;
|
||||
int8_t x = 0;
|
||||
int8_t y = 0;
|
||||
bool vertical = false;
|
||||
uint8_t length = 0;
|
||||
uint16_t framesLeft = 0; // Frames remaining in the current phase
|
||||
};
|
||||
|
||||
struct GameState {
|
||||
volatile uint16_t ticks = 0;
|
||||
volatile uint16_t snakelength = 0;
|
||||
@@ -29,6 +48,11 @@ struct GameState {
|
||||
|
||||
uint16_t curseTicksRemaining = 0;
|
||||
|
||||
// Fixed-size (no heap) because barriers are touched from both the VBlank
|
||||
// and Timer 0 IRQs. Those IRQs don't nest, so no further locking is needed.
|
||||
std::array<Barrier, BARRIER_MAX_COUNT> barriers{};
|
||||
volatile uint16_t barrierSpawnCooldown = 0; // Frames until the next spawn attempt
|
||||
|
||||
std::deque<std::array<int, 3>> snake;
|
||||
std::vector<std::array<int, 2>> apples;
|
||||
std::vector<std::array<int, 2>> bad_apples;
|
||||
|
||||
Reference in new issue
Block a user