-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (61 loc) · 1.39 KB
/
main.cpp
File metadata and controls
84 lines (61 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <raylib.h>
#include <raymath.h>
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
#include "Game/Game.hpp"
#include "UI/ui.hpp"
#include "utils.hpp"
#include "Engine/Transformation.hpp"
#include "Engine/Setup.hpp"
#include "SaveLoadData/SaveLoadData.hpp"
Game game;
void UpdateDrawFrame();
int main(void)
{
InitWindow(game.WIDTH, game.HEIGHT, "raylib [core] example - basic window");
game.WIDTH = GetScreenWidth();
game.HEIGHT = GetScreenHeight();
//ToggleFullscreen();
LoadData();
InitUI();
LuaEngineSetup();
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
UpdateDrawFrame();
}
#endif
SaveData();
CloseWindow();
return 0;
}
void UpdateDrawFrame()
{
game.lua["deltaTime"] = GetFrameTime();
if (!game.init_lua && game.run)
{
game.init_lua = true;
LuaEngineInit();
}
game.Update();
if (game.run)
LuaEngineUpdate();
BeginDrawing();
ClearBackground(game.background_color);
game.Draw();
if (game.run)
LuaEngineDraw();
DrawUI();
EndDrawing();
}