comparison clojure/com/aurellem/run/title.clj @ 256:c7b002525041

improved scroll-text to scroll through multiple lines of text
author Robert McIntyre <rlm@mit.edu>
date Mon, 26 Mar 2012 06:11:49 -0500
parents 5dafe6188ca5
children 8e63b0bb8ea3
comparison
equal deleted inserted replaced
255:d9e0752da684 256:c7b002525041
19 ([base alt [commands state]] 19 ([base alt [commands state]]
20 (advance base alt AF [commands state])) 20 (advance base alt AF [commands state]))
21 ([alt [commands state]] 21 ([alt [commands state]]
22 (advance [] alt [commands state]))) 22 (advance [] alt [commands state])))
23 23
24 (def scroll-text (partial advance [:b] [:a :b])) 24 (defn scroll-text
25 ([script]
26 (advance [:b] [:a :b] script))
27 ([n script]
28 (reduce (fn [script _]
29 (scroll-text script))
30 script
31 (range n))))
25 32
26 (defn start [] [[] (root)]) 33 (defn start [] [[] (root)])
27 34
28 (defn-memo title 35 (defn-memo title
29 ([] (title (start))) 36 ([] (title (start)))
36 43
37 (defn-memo oak 44 (defn-memo oak
38 ([] (oak (title))) 45 ([] (oak (title)))
39 ([script] 46 ([script]
40 (->> script 47 (->> script
41 scroll-text 48 (scroll-text 13))))
42 scroll-text
43 scroll-text
44 scroll-text
45 scroll-text
46 scroll-text
47 scroll-text
48 scroll-text
49 scroll-text
50 scroll-text
51 scroll-text
52 scroll-text
53 scroll-text)))
54 49
55 (defn-memo name-entry-rlm 50 (defn-memo name-entry-rlm
56 ([] (name-entry-rlm (oak))) 51 ([] (name-entry-rlm (oak)))
57 ([script] 52 ([script]
58 (->> script 53 (->> script
77 72
78 (defn-memo rival-name-entry-gary 73 (defn-memo rival-name-entry-gary
79 ([] (rival-name-entry-gary (name-entry-ash))) 74 ([] (rival-name-entry-gary (name-entry-ash)))
80 ([script] 75 ([script]
81 (->> script 76 (->> script
82 scroll-text 77 (scroll-text 5)
83 scroll-text
84 scroll-text
85 scroll-text
86 scroll-text
87 (advance [] [:d]) 78 (advance [] [:d])
88 (advance [] [:d]) 79 (advance [] [:d])
89 (advance [] [:a])))) 80 (advance [] [:a]))))
90 81
91 (defn-memo rival-name-entry-blue 82 (defn-memo rival-name-entry-blue
92 ([] (rival-name-entry-blue (name-entry-ash))) 83 ([] (rival-name-entry-blue (name-entry-ash)))
93 ([script] 84 ([script]
94 (->> script 85 (->> script
95 scroll-text 86 (scroll-text 5)
96 scroll-text
97 scroll-text
98 scroll-text
99 scroll-text
100 (advance [] [:d]) 87 (advance [] [:d])
101 (advance [] [:a])))) 88 (advance [] [:a]))))
102 89
103 (defn-memo finish-title 90 (defn-memo finish-title
104 ([] (finish-title (rival-name-entry-blue))) 91 ([] (finish-title (rival-name-entry-blue)))
105 ([script] 92 ([script]
106 (->> script 93 (->> script
107 scroll-text 94 (scroll-text 7))))
108 scroll-text 95
109 scroll-text
110 scroll-text
111 scroll-text
112 scroll-text
113 scroll-text)))
114
115 (def title-frames 2194) 96 (def title-frames 2194)
116 97
117 (defn title-checkpoint! [] 98 (defn title-checkpoint! []
118 (let [[moves state] (finish-title)] 99 (let [[moves state] (finish-title)]
119 (assert (= title-frames (count moves))) 100 (assert (= title-frames (count moves)))