Newer
Older
ESP32-RetroPlay / main / tasks / game / game_framework.h
#ifndef GAME_FRAMEWORK_H
#define GAME_FRAMEWORK_H

#include <stdbool.h>
#include "ssd1306.h" // Assuming ssd1306.h is common and needed for drawing functions
#include "freertos/queue.h" // Needed for QueueHandle_t

// Common OLED dimensions
#define OLED_WIDTH 128
#define OLED_HEIGHT 64

// Define the reserved area for the score (common for all games)
#define SCORE_DISPLAY_HEIGHT 16
#define GAME_PLAY_AREA_START_Y SCORE_DISPLAY_HEIGHT
#define GAME_PLAY_AREA_HEIGHT (OLED_HEIGHT - SCORE_DISPLAY_HEIGHT)

// Structure for the generic game interface
typedef struct game_t {
    void (*init_game)(void);
    void (*handle_input)(void);
    bool (*update_game_state)(void); // Returns true if game over
    void (*draw_game)(SSD1306_t *dev);
    int (*get_score)(void);
    bool (*is_active)(void);
    void (*set_active)(bool active);
    QueueHandle_t (*get_input_queue)(void); // Added: Function to get the game's input queue
} game_t;

#endif // GAME_FRAMEWORK_H