-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
62 lines (47 loc) · 1.07 KB
/
main.c
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
#include "indexing.h"
#include "io.h"
#include "macros.h"
#include "simulator.h"
#include "simulator_structs.h"
#include <raylib.h>
#if defined(PLATFORMWEB)
#include <emscripten/emscripten.h>
#endif
extern void SandInit(Generation *, Cell *);
Generation generation;
void UpdateDrawFrame();
int main() {
const Size2 SIMULATOR_SIZE = {300, 200};
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
InitWindow(600, 400, "Particle Simulator V3");
generation = NEW(Generation, SIMULATOR_SIZE);
HandleResize(&generation);
HideCursor();
#if defined(PLATFORMWEB)
emscripten_set_main_loop(UpdateDrawFrame, 60, 1);
#else
SetTargetFPS(60);
while (!WindowShouldClose()) {
UpdateDrawFrame();
}
#endif
DeleteGeneration(&generation);
CloseWindow();
return 0;
}
void UpdateDrawFrame() {
if (IsWindowResized()) {
HandleResize(&generation);
}
HandleUpdateSelectedIndex();
HandleUpdateDrawRadius();
HandleDraw(&generation);
update_gen(&generation);
BeginDrawing();
{
draw_gen(&generation);
DrawBrush(&generation);
DrawFPS(0, 0);
}
EndDrawing();
}