Fix canvas size.

This commit is contained in:
Phil Hagelberg 2018-11-30 17:40:07 -08:00
parent 6909ea5d4e
commit 6463ce4432
2 changed files with 9 additions and 8 deletions

View file

@ -2,7 +2,8 @@
(var time 0) (var time 0)
{:draw (fn draw [message] {:draw (fn draw [message]
(love.graphics.print "This window should close in 3s") 32 16) (love.graphics.print (: "This window should close in %0.2f seconds"
:format (- 3 time))) 32 16)
:update (fn update [dt set-mode] :update (fn update [dt set-mode]
(if (< counter 65535) (if (< counter 65535)
(set counter (+ counter 1)) (set counter (+ counter 1))

View file

@ -1,5 +1,6 @@
(local repl (require "lib.stdio")) (local repl (require "lib.stdio"))
(local canvas (love.graphics.newCanvas 720 450)) (local canvas (let [(w h) (love.window.getMode)]
(love.graphics.newCanvas w h)))
(var scale 1) (var scale 1)
@ -16,6 +17,8 @@
(repl.start)) (repl.start))
(fn love.draw [] (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.setCanvas canvas)
(love.graphics.clear) (love.graphics.clear)
(love.graphics.setColor 1 1 1) (love.graphics.setColor 1 1 1)
@ -25,14 +28,11 @@
(love.graphics.draw canvas 0 0 0 scale scale)) (love.graphics.draw canvas 0 0 0 scale scale))
(fn love.update[dt] (fn love.update[dt]
(mode.update dt set-mode) (mode.update dt set-mode))
)
(fn love.keypressed [key] (fn love.keypressed [key]
(if (if
(and (love.keyboard.isDown "lctrl" "rctrl" "capslock") (= key "q")) (and (love.keyboard.isDown "lctrl" "rctrl" "capslock") (= key "q"))
(love.event.quit) (love.event.quit)
;; add what each keypress should do in each mode ;; add what each keypress should do in each mode
(mode.keypressed key set-mode) (mode.keypressed key set-mode)))
))