view clojure/com/aurellem/run/title.clj @ 324:7876781520ea

fixed set-cursor so that moving the cursor backwards works
author Robert McIntyre <rlm@mit.edu>
date Wed, 04 Apr 2012 01:04:06 -0500
parents 9a4d3f801c89
children a452deec2882
line wrap: on
line source
1 (ns com.aurellem.run.title
2 (:use (com.aurellem.gb gb-driver vbm))
3 (:use (com.aurellem.run util)))
5 (defn start [] [[] (root)])
7 (defn-memo title
8 ([] (title (start)))
9 ([script]
10 (->> script
11 (first-difference [] [:a] AF)
12 (first-difference [] [:start] AF)
13 (first-difference [] [:a] AF)
14 (first-difference [] [:start] AF))))
16 (defn-memo oak
17 ([] (oak (title)))
18 ([script]
19 (->> script
20 (scroll-text 13))))
22 (defn-memo name-entry-rlm
23 ([] (name-entry-rlm (oak)))
24 ([script]
25 (->> script
26 (first-difference [] [:a] AF)
27 (first-difference [] [:r] DE)
28 (play-moves
29 [[]
30 [:r] [] [:r] [] [:r] [] [:r] []
31 [:r] [] [:r] [] [:r] [] [:d] [:a]
32 [:l] [] [:l] [] [:l] [] [:l] []
33 [:l] [] [:l] [:a] [] [:r] [:a]
34 [:r] [] [:r] [] [:r] [] [:r] []
35 [:r] [] [:d] [] [:d] [] [:d] [:a]]))))
37 (defn-memo name-entry-ash
38 ([] (name-entry-ash (oak)))
39 ([script]
40 (->> script
41 (first-difference [] [:d] AF)
42 (first-difference [] [:d] AF)
43 (first-difference [] [:a] AF))))
45 (defn-memo rival-name-entry-gary
46 ([] (rival-name-entry-gary (name-entry-ash)))
47 ([script]
48 (->> script
49 (scroll-text 5)
50 (first-difference [] [:d] AF)
51 (first-difference [] [:d] AF)
52 (first-difference [] [:a] AF))))
54 (defn-memo rival-name-entry-blue
55 ([] (rival-name-entry-blue (name-entry-ash)))
56 ([script]
57 (->> script
58 (scroll-text 5)
59 (first-difference [] [:d] AF)
60 (first-difference [] [:a] AF))))
62 (defn-memo finish-title
63 ([] (finish-title (rival-name-entry-blue)))
64 ([script]
65 (->> script
66 (scroll-text 7))))
68 (def title-frames 2194)
70 (defn title-checkpoint! []
71 (let [[moves state] (finish-title)]
72 (assert (= title-frames (count moves)))
73 [(write-moves! moves "title-checkpoint")
74 (write-state! state "title-checkpoint")]))
76 (defn intro []
77 [(read-moves "title-checkpoint")
78 (read-state "title-checkpoint")])
80 (defn test-intro []
81 (play-vbm (moves-filename "title-checkpoint")))
83 ;; TODO might be able to glue these together more elegantly with monads