annotate clojure/com/aurellem/run/title.clj @ 314:073600cba28a

scroll text works robustly but is slow
author Robert McIntyre <rlm@mit.edu>
date Mon, 02 Apr 2012 20:30:02 -0500
parents 8e63b0bb8ea3
children 9a4d3f801c89
rev   line source
rlm@170 1 (ns com.aurellem.run.title
rlm@170 2 (:use (com.aurellem.gb gb-driver vbm)))
rlm@81 3
rlm@81 4
rlm@87 5 (defn start [] [[] (root)])
rlm@81 6
rlm@250 7 (defn-memo title
rlm@250 8 ([] (title (start)))
rlm@250 9 ([script]
rlm@250 10 (->> script
rlm@250 11 (advance [] [:a])
rlm@250 12 (advance [] [:start])
rlm@250 13 (advance [] [:a])
rlm@250 14 (advance [] [:start]))))
rlm@81 15
rlm@250 16 (defn-memo oak
rlm@250 17 ([] (oak (title)))
rlm@250 18 ([script]
rlm@250 19 (->> script
rlm@256 20 (scroll-text 13))))
rlm@81 21
rlm@250 22 (defn-memo name-entry-rlm
rlm@250 23 ([] (name-entry-rlm (oak)))
rlm@250 24 ([script]
rlm@250 25 (->> script
rlm@250 26 (advance [] [:a])
rlm@250 27 (advance [] [:r] DE)
rlm@250 28 (play-moves
rlm@250 29 [[]
rlm@250 30 [:r] [] [:r] [] [:r] [] [:r] []
rlm@250 31 [:r] [] [:r] [] [:r] [] [:d] [:a]
rlm@250 32 [:l] [] [:l] [] [:l] [] [:l] []
rlm@250 33 [:l] [] [:l] [:a] [] [:r] [:a]
rlm@250 34 [:r] [] [:r] [] [:r] [] [:r] []
rlm@250 35 [:r] [] [:d] [] [:d] [] [:d] [:a]]))))
rlm@91 36
rlm@250 37 (defn-memo name-entry-ash
rlm@250 38 ([] (name-entry-ash (oak)))
rlm@250 39 ([script]
rlm@250 40 (->> script
rlm@250 41 (advance [] [:d])
rlm@250 42 (advance [] [:d])
rlm@250 43 (advance [] [:a]))))
rlm@91 44
rlm@250 45 (defn-memo rival-name-entry-gary
rlm@250 46 ([] (rival-name-entry-gary (name-entry-ash)))
rlm@250 47 ([script]
rlm@250 48 (->> script
rlm@256 49 (scroll-text 5)
rlm@250 50 (advance [] [:d])
rlm@250 51 (advance [] [:d])
rlm@250 52 (advance [] [:a]))))
rlm@250 53
rlm@250 54 (defn-memo rival-name-entry-blue
rlm@250 55 ([] (rival-name-entry-blue (name-entry-ash)))
rlm@250 56 ([script]
rlm@250 57 (->> script
rlm@256 58 (scroll-text 5)
rlm@250 59 (advance [] [:d])
rlm@250 60 (advance [] [:a]))))
rlm@81 61
rlm@250 62 (defn-memo finish-title
rlm@250 63 ([] (finish-title (rival-name-entry-blue)))
rlm@250 64 ([script]
rlm@250 65 (->> script
rlm@256 66 (scroll-text 7))))
rlm@256 67
rlm@250 68 (def title-frames 2194)
rlm@89 69
rlm@89 70 (defn title-checkpoint! []
rlm@88 71 (let [[moves state] (finish-title)]
rlm@250 72 (assert (= title-frames (count moves)))
rlm@250 73 [(write-moves! moves "title-checkpoint")
rlm@250 74 (write-state! state "title-checkpoint")]))
rlm@88 75
rlm@88 76 (defn intro []
rlm@250 77 [(read-moves "title-checkpoint")
rlm@250 78 (read-state "title-checkpoint")])
rlm@88 79
rlm@88 80 (defn test-intro []
rlm@254 81 (play-vbm (moves-filename "title-checkpoint")))
rlm@88 82
rlm@87 83 ;; TODO might be able to glue these together more elegantly with monads
rlm@87 84