diff --git a/src/engine.clj b/src/engine.clj index cc3bbb6..a1ecf8f 100644 --- a/src/engine.clj +++ b/src/engine.clj @@ -84,17 +84,15 @@ (let [config (:config @game-config)] (try (doseq [buf @buffered-objs] (snapshot! buf)) - (swap! game-state #(update config %)) - (catch Throwable t - (doseq [buf @buffered-objs] - (restore! buf)) - (report-exception! t))) - (rl/with-drawing! - (try - (draw config @game-state) - (w/watch! (watch-fn config @game-state)) - (catch Throwable t - (report-exception! t))))))) + (let [updated-state (update config @game-state)] + (rl/with-drawing! + (draw config updated-state) + (w/watch! (watch-fn config updated-state)) + (swap! game-state updated-state) + (catch Throwable t + (doseq [buf @buffered-objs] + (restore! buf)) + (report-exception! t)))))))) (try (when unload (doseq [[_ tex] @texture-cache]