ad823b5ba9cd entry-02

fix typo
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Jul 2012 09:09:21 -0400
parents 17efffc997c6
children 94179c6aec42
branches/tags entry-02
files src/caves/core.clj

Changes

--- a/src/caves/core.clj	Sun Jul 08 07:31:45 2012 -0400
+++ b/src/caves/core.clj	Sun Jul 08 09:09:21 2012 -0400
@@ -14,6 +14,30 @@
       (s/put-string screen 0 row blank))))
 
 
+; Drawing ---------------------------------------------------------------------
+(defmulti draw-ui
+  (fn [ui game screen]
+    (:kind ui)))
+
+(defmethod draw-ui :start [ui game screen]
+  (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
+  (s/put-string screen 0 1 "Press enter to win, anything else to lose."))
+
+(defmethod draw-ui :win [ui game screen]
+  (s/put-string screen 0 0 "Congratulations, you win!")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
+
+(defmethod draw-ui :lose [ui game screen]
+  (s/put-string screen 0 0 "Sorry, better luck next time.")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
+
+(defn draw-game [game screen]
+  (clear-screen screen)
+  (doseq [ui (:uis game)]
+    (draw-ui ui game screen))
+  (s/redraw screen))
+
+
 ; Input -----------------------------------------------------------------------
 (defmulti process-input
   (fn [game input]
@@ -38,30 +62,6 @@
   (assoc game :input (s/get-key-blocking screen)))
 
 
-; Drawing ---------------------------------------------------------------------
-(defmulti draw-ui
-  (fn [ui game screen]
-    (:kind ui)))
-
-(defmethod draw-ui :start [ui game screen]
-  (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
-  (s/put-string screen 0 1 "Press enter to win, anything else to lose."))
-
-(defmethod draw-ui :win [ui game screen]
-  (s/put-string screen 0 0 "Congratulations, you win!")
-  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
-
-(defmethod draw-ui :lose [ui game screen]
-  (s/put-string screen 0 0 "Sorry, better luck next time.")
-  (s/put-string screen 0 1 "Press escape to exit, anything else to go."))
-
-(defn draw-game [game screen]
-  (clear-screen screen)
-  (doseq [ui (:uis game)]
-    (draw-ui ui game screen))
-  (s/redraw screen))
-
-
 ; Main ------------------------------------------------------------------------
 (defn run-game [game screen]
   (loop [{:keys [input uis] :as game} game]