-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrap.fnl
39 lines (32 loc) · 1.09 KB
/
wrap.fnl
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
(local repl (require "lib.stdio"))
(local canvas (let [(w h) (love.window.getMode)]
(love.graphics.newCanvas w h)))
(var scale 1)
;; set the first mode
(var mode (require "intro"))
(fn set-mode [mode-name ...]
(set mode (require mode-name))
(when mode.activate
(mode.activate ...)))
(fn love.load []
(love.window.setTitle "Backpackless")
(love.graphics.setDefaultFilter "nearest" "nearest")
(repl.start))
(fn love.draw []
;; the canvas allows you to get sharp pixel-art style scaling; if you
;; don't want that, just skip that and call mode.draw directly.
(love.graphics.setCanvas canvas)
(love.graphics.clear)
(love.graphics.setColor 1 1 1)
(mode.draw)
(love.graphics.setCanvas)
(love.graphics.setColor 1 1 1)
(love.graphics.draw canvas 0 0 0 scale scale))
(fn love.update [dt]
(mode.update dt set-mode))
(fn love.keypressed [key]
(if
(and (love.keyboard.isDown "lctrl" "rctrl" "capslock") (= key "q"))
(love.event.quit)
;; add what each keypress should do in each mode
(mode.keypressed key set-mode)))