Commits

Steve Losh committed 3152de9

Minor refactorings suggested by Gery Debongnie.

  • Participants
  • Parent commits f15b817

Comments (0)

Files changed (3)

File src/caves/core.clj

 (defn run-game [game screen]
   (loop [{:keys [input uis] :as game} game]
     (when (seq uis)
-      (if (nil? input)
-        (let [game (update-in game [:world] tick-all)
-              _ (draw-game game screen)
-              game (clear-messages game)]
-          (recur (get-input game screen)))
-        (recur (process-input (dissoc game :input) input))))))
+      (recur (if input
+               (-> game
+                 (dissoc :input)
+                 (process-input input))
+               (-> game
+                 (update-in [:world] tick-all)
+                 (draw-game screen)
+                 (clear-messages)
+                 (get-input screen)))))))
 
 (defn new-game []
   (->Game nil [(->UI :start)] nil {:show-regions false}))

File src/caves/ui/drawing.clj

   (s/clear screen)
   (doseq [ui (:uis game)]
     (draw-ui ui game screen))
-  (s/redraw screen))
+  (s/redraw screen)
+  game)

File src/caves/utils.clj

 
 
 (defn enumerate [s]
-  (map vector (iterate inc 0) s))
+  (map-indexed vector s))