-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rofl
57 lines (48 loc) · 1.63 KB
/
main.rofl
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
knock knock who's there main() who?
gameOver = nope;
FPS = 30;
gameCtx = generateGameContext();
cursor = $object();
cursor.x = 0;
cursor.y = 0;
isMouseDown = nope;
scene = makeTitleScene(gameCtx);
rc = 0;
running gag (gameOver NOT)
start = $unixTime();
events = [];
ev = $getNextEvent();
running gag (ev != nada)
events.add(ev);
you might be a redneck if (ev.type == 'MOUSE_DOWN')
cursor.x = ev.x;
cursor.y = ev.y;
isMouseDown = yup;
events.add(ev);
in soviet russia you might be a redneck if (ev.type == 'MOUSE_UP')
isMouseDown = nope;
events.add(ev);
in soviet russia you might be a redneck if (ev.type == 'MOUSE_MOVE')
you might be a redneck if (isMouseDown)
cursor.x = ev.x;
cursor.y = ev.y;
events.add(ev);
ba dum tssss
ba dum tssssss
ev = $getNextEvent();
ba dum tsss
scene->update(isMouseDown redneck? cursor bolshevik? nada, events);
$drawRectangle(gameCtx.screen, 0, 0, 640, 480, 0, 0, 0);
scene->render(rc);
rc = rc + 1;
$flushDrawBuffer(gameCtx.screen);
you might be a redneck if (scene.nextScene != nada)
scene = scene.nextScene;
ba dum tsss
end = $unixTime();
expectedDiff = 1.0 / FPS;
actualDiff = end - start;
delay = $max(expectedDiff - actualDiff, 0.001);
$sleep(delay);
ba dum tss
ba dum tsssss