blob: a070382e077d6fe94359b59f42e710faffdc202e (
plain)
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
|
#include <raylib.h>
#include <emscripten.h>
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char **argv) {
InitWindow(240, 160, "test game raylib mode");
SetTargetFPS(60);
emscripten_run_script("window.parent.postMessage({op: \"ready\"});");
bool started = false;
while (!WindowShouldClose()) {
if (!started) {
double difficulty = EM_ASM_DOUBLE({return window.lcolonqJamStart || -1.0;});
printf("difficulty: %f\n", difficulty);
if (difficulty > 0.0) {
started = true;
emscripten_run_script("window.parent.postMessage({op: \"started\"});");
printf("started at difficulty: %f\n", difficulty);
}
} else {
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
printf("clicked\n");
emscripten_run_script("window.parent.postMessage({op: \"done\", win: false});");
started = false;
}
BeginDrawing();
ClearBackground(RED);
DrawText("hello gamer", 0, 0, 20, WHITE);
EndDrawing();
}
}
return 0;
}
|