ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
Game.h
浏览该文件的文档.
1#pragma once
2#include "Core.h"
3
4namespace Shit {
16 class SHIT_API Game {
17 public:
20
21 bool init();
22 void run();
23
24 // --- 静态API ---
25 static Game& GetInstance();
26 inline static bool Init() { return GetInstance().init(); }
27 inline static void Run() { GetInstance().run(); }
28 inline static void Destroy() { GetInstance().destroy(); }
29 static bool IsRunning() { return GetInstance().m_isRunning; }
30 inline static void SetPaused(bool paused) { GetInstance().m_isPaused = paused; }
31 inline static bool IsPaused() { return GetInstance().m_isPaused; }
32
33 Game(const Game&) = delete;
34 Game& operator=(const Game&) = delete;
35 Game(Game&&) = delete;
36 Game& operator=(Game&&) = delete;
37
38 private:
39 void destroy();
40
41 bool m_isRunning = false;
42 bool m_isInited = false;
43 bool m_isPaused = false;
44 };
45}
#define SHIT_API
定义 Core.h:14
static bool IsPaused()
是否处于暂停状态
定义 Game.h:31
Game & operator=(Game &&)=delete
void run()
启动主循环(阻塞直至窗口关闭)
Game & operator=(const Game &)=delete
Game(const Game &)=delete
static void SetPaused(bool paused)
全局暂停(冻结 Behavior/物理,UI 叠层照常)
定义 Game.h:30
static void Destroy()
反初始化,按依赖逆序清理子系统(init 部分失败时也能安全调用)
定义 Game.h:28
static bool IsRunning()
主循环是否仍在运行
定义 Game.h:29
static void Run()
定义 Game.h:27
static Game & GetInstance()
static bool Init()
定义 Game.h:26
bool init()
初始化引擎所有子系统
Game(Game &&)=delete
定义 AudioPlayer.h:10