Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Game.hpp
1#pragma once
2
3#include "GameMenu.hpp"
4#include "GameMenuRenderer.hpp"
5#include "GameRenderer.hpp"
6#include "system/Window.hpp"
7#include "system/Config.hpp"
8#include "processing/GaussianBlur.hpp"
9#include <map>
10
11// *** Later improvements: ***
12// \todo Add match-3 mechanics.
13// \todo High score list or best score display.
14
15
20public:
21
25 GameConfig(const std::vector<std::string> & argv);
26
29 void save();
30
31 bool lowRes = false;
32
33};
34
39class Game {
40public:
44 explicit Game(GameConfig & config);
45
49 void draw(Window & window);
50
55
59 void physics(double frameTime);
60
65 void resize(unsigned int width, unsigned int height);
66
67private:
71 enum class Status {
72 MAINMENU,
73 INGAME,
74 PAUSED,
75 DEAD,
76 OPTIONS
77 };
78
82 enum ButtonAction : int {
83 NEWGAME,
84 OPTIONS,
85 QUIT,
86 PAUSE,
87 RESUME,
88 BACKTOMENU,
89 OPTION_FULLSCREEN,
90 OPTION_VSYNC,
91 OPTION_HALFRES
92 };
93
99
101 std::unique_ptr<Player> _player;
102
105 std::unique_ptr<GaussianBlur> _bgBlur;
109
110 Status _status = Status::MAINMENU;
111 std::map<Status, GameMenu> _menus;
112
113 double _playTime = 0.0;
114 bool _overrideTime = false;
115};
Game common configuration.
Definition: Game.hpp:19
bool lowRes
Perform internal rendering at a lower resolution.
Definition: Game.hpp:31
void save()
Definition: Game.cpp:20
Handles communication between the different game components (renderers, player, menus) and the player...
Definition: Game.hpp:39
Texture _gameResult
Game scene texture.
Definition: Game.hpp:106
ButtonAction
Action that can be performed by pressing a button or a key.
Definition: Game.hpp:82
void draw(Window &window)
Definition: Game.cpp:103
GameMenuRenderer _menuRenderer
Menus renderer.
Definition: Game.hpp:104
std::unique_ptr< GaussianBlur > _bgBlur
Blurring pass for the paused/dead menus background.
Definition: Game.hpp:105
double _playTime
Current playtime.
Definition: Game.hpp:113
Status _status
Current game sattus (specific menu or in-game)
Definition: Game.hpp:110
Program * _finalProgram
Final upscaling program.
Definition: Game.hpp:108
Window::Action update()
Definition: Game.cpp:127
bool _overrideTime
Debug pause.
Definition: Game.hpp:114
GameRenderer _inGameRenderer
In-game renderer.
Definition: Game.hpp:103
void resize(unsigned int width, unsigned int height)
Definition: Game.cpp:261
Status
Game state: either a specific menu or in-game.
Definition: Game.hpp:71
std::unique_ptr< Player > _player
The player state.
Definition: Game.hpp:101
Window::Action handleButton(ButtonAction tag)
Definition: Game.cpp:205
std::map< Status, GameMenu > _menus
Menus for each game status.
Definition: Game.hpp:111
Texture _bgBlurTexture
Blurred game scene texture.
Definition: Game.hpp:107
GameConfig & _config
Reference to the shared game configuration.
Definition: Game.hpp:100
void physics(double frameTime)
Definition: Game.cpp:247
Renders a game menu.
Definition: GameMenuRenderer.hpp:11
Renders the main game scene.
Definition: GameRenderer.hpp:13
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Configuration containing parameters for windows and renderers.
Definition: Config.hpp:113
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
Represent an OS window and its associated rendering context.
Definition: Window.hpp:14
Action
Definition: Window.hpp:28