4
<title>A Denemo Keymap</title>
5
<author>AT, JRR, RTS</author>
8
<action>LineOrSpace</action>
9
<scheme>;;;;;;;;;;;;;;;
11
;; tests note name recognition.
13
(define LineOrSpace::positionwas #t)
14
(define LineOrSpace::acceptable_input (list "l" "space"))
15
(define LineOrSpace::userinput #t)
16
(define LineOrSpace::start (current-time))
17
(define LineOrSpace::end (current-time))
18
(define LineOrSpace::score 0)
19
(define LineOrSpace::steps 0)
20
(define LineOrSpace::position 6) ;in middle c offset
21
(define LineOrSpace::note_highest 12)
22
(define LineOrSpace::note_lowest 0)
23
(define LineOrSpace::span 8) ;; how many LineOrSpace::steps of the scale to test.
24
(define LineOrSpace::num-goes 30) ;; how many notes to present for the whole test
25
(define LineOrSpace::input_device 1) ;0 = mouse 1 = keyboard
27
(define (LineOrSpace::showscore)
28
(d-DirectivePut-score-display "LineOrSpace::GameScore" (string-append "<b>Score: " (object->string LineOrSpace::score) "</b> in " (object->string (- LineOrSpace::end LineOrSpace::start)) " Secs.")))
30
(define (LineOrSpace::help)
31
(d-InfoDialog "Click on the *Spacebar* if the note is on a space and the *L* key if it is on a line.")
34
(define (LineOrSpace::GameOver)
35
(d-InfoDialog (string-append "Game Over\n" "Your Score = " (number->string LineOrSpace::score)))
38
(define (LineOrSpace::ScoreBoard)
39
(d-InfoDialog (EducationGames::Scoreboard_Pretty_Print
40
(EducationGames::ScoreboardFile "LineOrSpace")))
43
(CreateButton "LineOrSpace::GameScore" "<span font_desc=\"12\">Score</span>")
44
(d-SetDirectiveTagActionScript "LineOrSpace::GameScore" "(LineOrSpace::ScoreBoard)")
45
(CreateButton "LineOrSpace::GameHelp" "<b>Help</b>")
46
(d-SetDirectiveTagActionScript "LineOrSpace::GameHelp" "(LineOrSpace::help)")
48
(define (LineOrSpace::offerNote)
56
(or (> LineOrSpace::position LineOrSpace::note_highest)
57
(> LineOrSpace::note_lowest LineOrSpace::position))
61
(set! interval (random 4))
63
(set! LineOrSpace::position (+ LineOrSpace::position interval))
64
(set! LineOrSpace::position (- LineOrSpace::position interval)))
71
(let gotoEnd () (if (d-NextObject) (gotoEnd)))
73
(d-CursorToNote (EducationalGames::middle_c_offset->lily LineOrSpace::position))
75
(if (or (even? LineOrSpace::position)
76
(= 0 LineOrSpace::position))
77
(set! LineOrSpace::positionwas "line")
78
(set! LineOrSpace::positionwas "space"))
80
(LineOrSpace::showscore)
83
;;;;;;;;; callback when user chooses a note
84
(define (LineOrSpace::positionchosen userinput)
85
(if (> LineOrSpace::num-goes 0)
87
(set! LineOrSpace::end (current-time))
88
(let gotoEnd () (if (d-NextObject) (gotoEnd)))
89
(if (string=? LineOrSpace::positionwas userinput)
91
(set! LineOrSpace::score (+ LineOrSpace::score 1))
92
(EducationGames::PlaceAnswerStatus "CheckMark"))
94
(set! LineOrSpace::score (- LineOrSpace::score 1))
95
(EducationGames::PlaceAnswerStatus "CrossSign")))
97
(if (= LineOrSpace::input_device 0)
99
(set! LineOrSpace::num-goes (- LineOrSpace::num-goes 1))
100
(if (= LineOrSpace::num-goes 0)
101
(LineOrSpace::EndGame))
103
(if (> LineOrSpace::num-goes 0)
104
(LineOrSpace::offerNote))
108
;;;;;;;; the main function to run the test
109
(define LineOrSpace::runtest
112
(set! LineOrSpace::userinput (EducationGames::GetAcceptableKeyInput LineOrSpace::acceptable_input))
113
(if (string=? LineOrSpace::userinput "l")
114
(set! LineOrSpace::userinput "line"))
115
(LineOrSpace::positionchosen LineOrSpace::userinput)
116
(LineOrSpace::runtest (- n 1))))))
119
(define (LineOrSpace::createbuttons position)
120
(CreateButton (string-append "LineOrSpace::" position) (string-append " <span font_desc=\"32\" foreground=\"blue\">" position "</span>"))
121
(d-SetDirectiveTagActionScript (string-append "LineOrSpace::" position) (string-append "(LineOrSpace::positionchosen \"" position "\")")))
123
(define (LineOrSpace::EndGame)
124
(EducationGames::Chime)
126
(EducationGames::Write_Scoreboard_File
127
(EducationGames::ScoreboardFile "LineOrSpace") LineOrSpace::score))
128
(LineOrSpace::GameOver)
129
(LineOrSpace::ScoreBoard)
134
(define (LineOrSpace::go)
135
(if (not (zero? LineOrSpace::score))
137
(set! response (d-GetUserInput "Reset Score" "Do you want to reset your score" "y"))
138
(if (equal? response "y")
140
(set! LineOrSpace::start (current-time))
141
(set! LineOrSpace::end (current-time))
143
(set! LineOrSpace::score 0)))))
144
(d-DeletePreviousObject)
145
(if (= LineOrSpace::input_device 0)
147
(LineOrSpace::createbuttons "line")
148
(LineOrSpace::createbuttons "space")
149
(EducationGames::Chime)
150
(LineOrSpace::offerNote)
153
(EducationGames::Chime)
154
(LineOrSpace::offerNote)
155
(LineOrSpace::runtest LineOrSpace::num-goes)
156
(LineOrSpace::EndGame))
160
(CreateButton "LineOrSpace::GameScore" "<span font_desc=\"32\">Click to start</span>")
161
(d-SetDirectiveTagActionScript "LineOrSpace::GameScore" "(LineOrSpace::go)")
164
(define (LineOrSpace::Input_Select)
165
(if (= LineOrSpace::input_device 0)
167
(set! LineOrSpace::input_device 1)
168
(d-DirectivePut-score-display "LineOrSpace::SetInput" "<span font_desc=\"12\">Input:keyboard</span>")
171
(set! LineOrSpace::input_device 0)
172
(d-DirectivePut-score-display "LineOrSpace::SetInput" "<span font_desc=\"12\">Input:mouse</span>")
176
(CreateButton "LineOrSpace::SetInput" "<span font_desc=\"12\">Input:keyboard</span>")
177
(d-SetDirectiveTagActionScript "LineOrSpace::SetInput" "(LineOrSpace::Input_Select)")
180
<label>Line and space recognition</label>
181
<tooltip>%tests your ability to recognize the difference between line and space</tooltip>