ShitEngine 1.4.2
基于 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; }
33 static void SetIsRunning(bool running) { GetInstance().m_isRunning = running; }
34 inline static void SetPaused(bool paused) { GetInstance().m_isPaused = paused; }
35 inline static bool IsPaused() { return GetInstance().m_isPaused; }
36
37 Game(const Game&) = delete;
38 Game& operator=(const Game&) = delete;
39 Game(Game&&) = delete;
40 Game& operator=(Game&&) = delete;
41
42 private:
43 void destroy();
44
45 bool m_isRunning = false;
46 bool m_isInited = false;
47 bool m_isPaused = false;
48 };
49}
#define SHIT_API
定义 Core.h:14
static bool IsPaused()
是否处于暂停状态
定义 Game.h:35
Game & operator=(Game &&)=delete
void run()
启动主循环(阻塞直至窗口关闭)
Game & operator=(const Game &)=delete
Game(const Game &)=delete
static void SetPaused(bool paused)
全局暂停(冻结 Behavior/物理,UI 叠层照常)
定义 Game.h:34
static void SetIsRunning(bool running)
标记运行态。编辑器内嵌预览(外部驱动主循环,不调用 run())在播放期间 置 true,使 Scene 增删走与 Runtime 一致的延时安全路径(帧末统一删除/添加), 游戏逻辑在迭代中删除对象不...
定义 Game.h:33
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
定义 AnimationClip.h:12