From 78530480d35be5dbb57f1a264147bec48d6cf800 Mon Sep 17 00:00:00 2001 From: equa Date: Sun, 18 Apr 2021 14:45:55 -0500 Subject: visual changes (zooming) and optimization also profiling --- lib/main.fnl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'lib/main.fnl') diff --git a/lib/main.fnl b/lib/main.fnl index 4a9d26e..03383ad 100644 --- a/lib/main.fnl +++ b/lib/main.fnl @@ -2,6 +2,8 @@ (local proto (require :lib.proto)) (local state (require :lib.state)) (local game (require :lib.game)) +(local profi (require :vendor.ProFi)) +(local profi? false) ;; i am thinking we could actually do a really hacky thing (modules add themselves ;; to this list) with this later but @@ -16,6 +18,10 @@ ;; oh thats why it doesnt work lmao (fn love.load [] + (when profi? + (profi:start)) + (set love.frame 0) + (love.keyboard.setKeyRepeat true) (global the-state (state.init game)) (global messages {}) (print "a")) @@ -42,6 +48,13 @@ ;; TODO: we need a better way to display errors at runtime for updates too (fn love.update [] + (when profi? + (profi:startHooks) + (set love.frame (+ love.frame 1)) + (when (= (% love.frame 100) 0) + (profi:stop) + (profi:writeReport) + (os.exit))) ;; TODO: make state changes actually possible (match (pcall #(state.update the-state)) (true x) nil @@ -49,10 +62,18 @@ (print (.. "update: \n" x)) (table.insert messages {:ticks 1 - :msg (.. "update: \n" x)})))) + :msg (.. "update: \n" x)}))) + (when profi? + (profi:stopHooks))) (fn love.keypressed [key scancode repeat] - ;; (print key scancode repeat) + (match (pcall #(state.keypressed the-state key scancode repeat)) + (true x) nil + (false x) (do + (print (.. "keypressed: \n" x)) + (table.insert messages + {:ticks 5 + :msg (.. "keypressed: \n" x)}))) (when (= key "r") (each [k v (lume.ripairs messages)] (when (= v.type :reload-error) -- cgit 1.3.0-6-gf8a5