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