aboutsummaryrefslogtreecommitdiff
path: root/src/games/Game.hpp
blob: 94d50cb3b593aeca5545596922a316c129496f27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <common/defs.hpp>

#include <SDL3/SDL.h>

#include <memory>
#include <vector>


class Game {
public:
    enum GameType {
        no_game,
        minesweeper,
        snake,
        tetris
    };

    enum GameStatus {
        game_starting,
        game_resuming,
        game_over,
        game_paused,
        game_exit
    };

    static std::unique_ptr<Game> Select(GameType type);


    Game() = default;
    virtual ~Game() = default;
    virtual bool Update(std::vector<SDL_Event>& events) = 0;


protected:
    void DrawGameOverMenu();
    void DrawGamePausedMenu();

    float ProcessDt();

    GameStatus m_game_status {game_starting};
    float m_dt_remaining_seconds {0.0f};
    uint64_t m_tlast_milliseconds {SDL_GetTicks()};
};