This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-26
Channels
- # announcements (28)
- # asami (13)
- # babashka (10)
- # beginners (170)
- # boot (1)
- # calva (35)
- # cider (21)
- # circleci (13)
- # clara (6)
- # clj-http (1)
- # clj-kondo (29)
- # cljdoc (5)
- # clojure (89)
- # clojure-czech (2)
- # clojure-europe (20)
- # clojure-france (16)
- # clojure-nl (6)
- # clojure-uk (5)
- # clojurescript (80)
- # community-development (6)
- # conjure (13)
- # cursive (18)
- # datascript (9)
- # datomic (1)
- # duct (1)
- # gratitude (2)
- # helix (7)
- # jobs (2)
- # kaocha (3)
- # lsp (22)
- # malli (5)
- # meander (1)
- # other-languages (34)
- # pathom (18)
- # polylith (24)
- # quil (10)
- # re-frame (5)
- # releases (1)
- # remote-jobs (4)
- # reveal (7)
- # shadow-cljs (8)
- # tools-deps (53)
In my program right now I do (frame-rate 30)
in my setup function and then everything renders at 30fps. However, I have a static background which doesn't need to re-render after the first time. It is possible to either do a 'draw once', or set the frame-rate on the background to a much lower rate, like 1?
(I think I might have asked this before on this channel a while ago but I didn't note down the response 馃槥 )
you can render your background in your setup function once, then it won't be re-rendered in the draw function
simple example here: http://quil.info/sketches/show/856cf5fa9b9ed5ac07bfc543d333c467a4a7c26337c3e1cc5b313f0e9279030e
you can make nice things with keeping the background, like a fading trail of a moving object: http://quil.info/sketches/show/10c044351a714e7dcba00e4e91a48e0e5ed655c591d1b0038547f2a1dfca5dd0
Hm, this isn't working like I expected. I draw the background in setup, it stays for one frame, and then disappears on the second frame! This is the setup function
(defn setup []
(q/frame-rate 1)
(let [ss (-> game-state
(assoc :cursor [(int (/ horiz-tiles 2)) (int (/ vert-tiles 2))]
:images (load-sprites))
add-sprites-to-units)]
(draw-terrain (vals (:field ss)) (:images ss))
ss))
And https://github.com/RedPenguin101/pocket-gettysburg/blob/main/src/general_slim/ui.clj#L122 is the full filethe problem is you are overwriting the background in draw-state
by calling q/background
(line 227)