Add exit game function
This commit is contained in:
@@ -25,6 +25,8 @@ typedef struct BzAppDesc {
|
|||||||
|
|
||||||
extern bool bzMain(BzAppDesc *appDesc, int argc, const char **argv);
|
extern bool bzMain(BzAppDesc *appDesc, int argc, const char **argv);
|
||||||
|
|
||||||
|
void bzGameExit();
|
||||||
|
|
||||||
#ifdef BZ_ENTRYPOINT
|
#ifdef BZ_ENTRYPOINT
|
||||||
#include <rlImGui.h>
|
#include <rlImGui.h>
|
||||||
|
|
||||||
@@ -62,6 +64,11 @@ static void bzRaylibLogger(int msgType, const char *text, va_list args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static BzAppDesc appDesc = {0, 0};
|
static BzAppDesc appDesc = {0, 0};
|
||||||
|
static bool running = true;
|
||||||
|
|
||||||
|
void bzGameExit() {
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
|
||||||
static void bzGameLoopTick() {
|
static void bzGameLoopTick() {
|
||||||
float dt = GetFrameTime();
|
float dt = GetFrameTime();
|
||||||
@@ -124,7 +131,7 @@ int main(int argc, const char **argv) {
|
|||||||
#ifdef PLATFORM_WEB
|
#ifdef PLATFORM_WEB
|
||||||
emscripten_set_main_loop(bzGameLoopTick, 0, 1);
|
emscripten_set_main_loop(bzGameLoopTick, 0, 1);
|
||||||
#else
|
#else
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose() && running) {
|
||||||
bzGameLoopTick();
|
bzGameLoopTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -310,6 +310,9 @@ void imguiRender(float dt, void *userData) {
|
|||||||
if (igCollapsingHeader_TreeNodeFlags("Entities", 0)) {
|
if (igCollapsingHeader_TreeNodeFlags("Entities", 0)) {
|
||||||
igSliderFloat("Frame duration", &game->frameDuration, 0.0f, 1.0f, NULL, 0);
|
igSliderFloat("Frame duration", &game->frameDuration, 0.0f, 1.0f, NULL, 0);
|
||||||
}
|
}
|
||||||
|
if (igSmallButton("Quite game")) {
|
||||||
|
bzGameExit();
|
||||||
|
}
|
||||||
igEnd();
|
igEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user