mapcreator git · master
SDL3 2.5D game and engine using assets, with map editor
C++ 99.3%git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gzsrc/game/game.hpp raw
#pragma once
#include <SDL3/SDL.h>
#include <SDL3/SDL_mouse.h>
#include <memory>
#include <cassert>
#include <iostream>
#include "game/state_modify.hpp"
#include "game/state_playing.hpp"
#include "game/state_menu_main.hpp"
#include "audio/audio.hpp"
class Input;
class AnimatedCursor;
enum class NewGameState_e {
NONE,
NEW,
LOAD
};
// Game class encapsulating SDL initialization and loop
class Game {
public:
Game();
Game(Game&&);
~Game();
SDL_Rect win_size = {0,0,800, 600};
SDL_Window* window = nullptr;
SDL_Renderer* renderer = nullptr;
Audio* audio = nullptr;
AnimatedCursor* cursor = nullptr;
bool is_cheating = false;
std::unique_ptr<StatePlaying> state_playing;
GameState* state_current = nullptr;
GameState_e state_current_e = GameState_e::STATE_MENU_MAIN;
std::unique_ptr<GameState> state_temp;
std::string active_game_dir = "game_saves";
bool draw_frames = false;
Uint64 lastTicks;
bool running;
Input input;
bool state_changed = false;
void set_State(GameState_e state, NewGameState_e game_state_e = NewGameState_e::NONE);
void Run();
bool Save(const std::string &path) const;
bool Load(const std::string &path);
private:
void handle_Events();
void Update();
void Render();
};