Debian Codegraph @

dokidoki/examples/colors.lua

raw symbols SCIP
1 require "dokidoki.module" [[]]
2
3 require "glfw"
4 import(require "gl")
5
6 kernel = require "dokidoki.kernel"
7
8 function make_uber_scene (coefficient_of_awesomeness)
9 local time_until_change = 0
10 local color = {0, 0, 0, 0}
11
12 function handle_event (event)
13 if event.type == 'quit' or
14 event.type == 'key' and event.is_down and event.key == glfw.KEY_ESC then
15 kernel.abort_main_loop()
16 end
17 end
18
19 function update (dt)
20 time_until_change = time_until_change - dt
21 if time_until_change <= 0 then
22 time_until_change = time_until_change + 1 / coefficient_of_awesomeness
23 color = {math.random(), math.random(), math.random(), 0}
24 end
25 end
26
27 function draw ()
28 glClearColor(unpack(color))
29 glClear(GL_COLOR_BUFFER_BIT)
30 end
31
32 return {handle_event = handle_event, update = update, draw = draw}
33 end
34
35 kernel.start_main_loop(make_uber_scene(math.acos(-1)))