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
|
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/html5.h>
#endif
#include "raylib.h"
#include "text.h"
#include "s7.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
s7_scheme *s7;
s7_pointer s7_update_fn;
s7_pointer s7_draw_fn;
#ifdef __EMSCRIPTEN__
EM_BOOL main_loop_web(double time, void* userData) {
s7_call(s7, s7_update_fn, s7_list(s7, 0));
BeginDrawing();
ClearBackground(RAYWHITE);
s7_call(s7, s7_draw_fn, s7_list(s7, 0));
EndDrawing();
return EM_TRUE;
}
#else
void main_loop(){
s7_call(s7, s7_update_fn, s7_list(s7, 0));
BeginDrawing();
ClearBackground(RAYWHITE);
s7_call(s7, s7_draw_fn, s7_list(s7, 0));
EndDrawing();
}
#endif
int main(int argc, char* argv[]) {
s7 = s7_init();
// rl_text_define_methods(s7);
const int screen_width = 800;
const int screen_height = 600;
InitWindow(screen_width, screen_height, "SLGJ - 2024");
SetTargetFPS(60);
char filename[] = SCRIPTS_PATH"main.scm";
s7_load(s7, filename);
s7_update_fn = s7_name_to_value(s7, "update");
s7_draw_fn = s7_name_to_value(s7, "draw");
#ifdef __EMSCRIPTEN__
emscripten_request_animation_frame_loop(main_loop_web, 0);
#else
while (!WindowShouldClose()) {
main_loop();
}
CloseWindow();
#endif
return 0;
}
|