melee-roguelite/wrap.fnl

38 lines
1 KiB
Plaintext
Raw Normal View History

2018-10-17 18:32:39 -07:00
(local repl (require "lib.stdio"))
2018-11-30 17:40:07 -08:00
(local canvas (let [(w h) (love.window.getMode)]
(love.graphics.newCanvas w h)))
2018-10-17 18:32:39 -07:00
(var scale 1)
;; set the first mode
(var mode (require "mode-intro"))
(fn set-mode [mode-name ...]
(set mode (require mode-name))
(when mode.activate
(mode.activate ...)))
(fn love.load []
2019-09-22 15:38:01 -07:00
(canvas:setFilter "nearest" "nearest")
(repl.start))
2018-10-17 18:32:39 -07:00
(fn love.draw []
2019-09-22 15:38:01 -07:00
;; 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))
2018-10-17 18:32:39 -07:00
2019-09-22 15:38:01 -07:00
(fn love.update [dt]
(mode.update dt set-mode))
2018-10-17 18:32:39 -07:00
(fn love.keypressed [key]
2019-09-22 15:38:01 -07:00
(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)))