Files
HeisserDraht/game_logic.h
Jan Remmer Siebels 01e79a4eb2 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>
2026-02-22 00:24:52 +01:00

38 lines
780 B
C

#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