Initial implementation of HeisserDraht buzz wire game
ESP32-C3 based hot wire game with WS2812B LED effects, SSD1306 OLED display, debounced touch detection, and full game state machine (IDLE → COUNTDOWN → PLAYING → GAME_OVER). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
37
game_logic.h
Normal file
37
game_logic.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef GAME_LOGIC_H
|
||||
#define GAME_LOGIC_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// Game states
|
||||
enum GameState {
|
||||
STATE_IDLE,
|
||||
STATE_COUNTDOWN,
|
||||
STATE_PLAYING,
|
||||
STATE_GAME_OVER
|
||||
};
|
||||
|
||||
// Game data
|
||||
struct GameData {
|
||||
GameState state;
|
||||
uint8_t strikes;
|
||||
int score;
|
||||
unsigned long gameStartMs;
|
||||
unsigned long elapsedMs;
|
||||
uint8_t countdownValue; // 3, 2, 1, 0(GO!)
|
||||
unsigned long countdownStepMs;
|
||||
bool touchActive; // true while wire is being touched
|
||||
unsigned long lastTouchMs;
|
||||
unsigned long lastButtonMs;
|
||||
bool won; // true if timer ran out with strikes < MAX
|
||||
};
|
||||
|
||||
void gameInit();
|
||||
void gameUpdate();
|
||||
GameData& gameGetData();
|
||||
|
||||
// Called by main loop to check inputs
|
||||
void gameCheckStartButton();
|
||||
void gameCheckTouch();
|
||||
|
||||
#endif // GAME_LOGIC_H
|
||||
Reference in New Issue
Block a user