Proyecto Final - Turinmachin
Recreación del minijuego de matemáticas de Brain-Age usando redes neuronales
Loading...
Searching...
No Matches
game.h
Go to the documentation of this file.
1#ifndef INCLUDE_STATE_H
2#define INCLUDE_STATE_H
3
4#include <SDL3/SDL_events.h>
5#include <SDL3/SDL_render.h>
6#include <cstdint>
7#include <memory>
8#include <optional>
9#include <random>
10#include <vector>
11#include "common/agent.h"
13#include "game/render.h"
14
15namespace game {
16
17 class Game {
18 enum class State : std::uint8_t {
19 Playing,
20 WinTransition,
21 };
22
23 bool quit = false;
24
25 std::unique_ptr<common::IAgent<std::vector<double>, int>> agent;
26 std::mt19937 rng;
27
28 SDL_Renderer* renderer;
29 SDL_Texture* canvas_texture;
30
31 std::optional<std::unique_ptr<math::IEquation>> current_equation = std::nullopt;
32 std::vector<std::unique_ptr<math::IEquation>> solved_equations;
33 bool mouse_down = false;
34 float last_mouse_x = 0;
35 float last_mouse_y = 0;
36 std::optional<int> current_guess = std::nullopt;
37
38 State state = State::WinTransition;
39 double wait_delay = 0.0;
40
41 void transition();
42
43 void process_drawing();
44
45 public:
46 explicit Game(SDL_Renderer* renderer,
47 std::unique_ptr<common::IDigitAgent> agent,
48 std::mt19937 rng);
49
50 ~Game();
51
52 [[nodiscard]] auto should_quit() const -> bool;
53
54 void handle_event(const SDL_Event& event);
55
56 void update(double delta);
57
58 void clear_canvas() const;
59
60 void render(const ResourceManager& resources) const;
61 };
62
63} // namespace game
64
65#endif
void clear_canvas() const
Definition game.cpp:170
auto should_quit() const -> bool
Definition game.cpp:57
void update(double delta)
Definition game.cpp:136
Game(SDL_Renderer *renderer, std::unique_ptr< common::IDigitAgent > agent, std::mt19937 rng)
Definition game.cpp:31
void handle_event(const SDL_Event &event)
Definition game.cpp:61
~Game()
Definition game.cpp:51
void render(const ResourceManager &resources) const
Definition game.cpp:179
Definition constants.h:7
Definition render.h:8