Fork me on GitHub

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 馃槥 )

Ju位ian (he/him)12:10:45

you can render your background in your setup function once, then it won't be re-rendered in the draw function


Thank you!

Ju位ian (he/him)12:10:16

you can make nice things with keeping the background, like a fading trail of a moving object:


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))
    (draw-terrain (vals (:field ss)) (:images ss))
And is the full file


I'm assuming the problem is that I'm not using background to draw my background

Ju位ian (he/him)08:10:26

the problem is you are overwriting the background in draw-state by calling q/background (line 227)


Ah, thank you!