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
Thank you!
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 fileI'm assuming the problem is that I'm not using background to draw my background
Ah, thank you!
the problem is you are overwriting the background in draw-state by calling q/background (line 227)