melee-roguelite/wrap.fnl

39 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 []
2018-11-30 17:40:07 -08:00
(: canvas :setFilter "nearest" "nearest")
2018-10-17 18:32:39 -07:00
(repl.start))
(fn love.draw []
2018-11-30 17:40:07 -08: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.
2018-10-17 18:32:39 -07:00
(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]
2018-11-30 17:40:07 -08:00
(mode.update dt set-mode))
2018-10-17 18:32:39 -07:00
(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
2018-11-30 17:40:07 -08:00
(mode.keypressed key set-mode)))