~ubuntu-branches/ubuntu/oneiric/denemo/oneiric

« back to all changes in this revision

Viewing changes to actions/menus/MainMenu/Educational/CountSteps

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-10-27 08:00:18 UTC
  • mfrom: (1.3.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20101027080018-tuekd0869v8ptnqv
Tags: upstream-0.8.16
ImportĀ upstreamĀ versionĀ 0.8.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
<Denemo>
3
 
  <merge>
4
 
    <title>A Denemo Keymap</title>
5
 
    <author>AT, JRR, RTS</author>
6
 
    <map>
7
 
      <row>
8
 
        <action>CountSteps</action>
9
 
        <scheme>;;;;;;;;;;;;;;;
10
 
;;CountSteps
11
 
;; tests interval recognition.
12
 
(define CountSteps::score 0)
13
 
(define CountSteps::interval 3)
14
 
(define CountSteps::start (current-time))
15
 
(define CountSteps::end (current-time))
16
 
(define CountSteps::num-goes 30)
17
 
(define CountSteps::intervalwas #t)
18
 
(define CountSteps::acceptable_list (list "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
19
 
(define CountSteps::note_highest 12)
20
 
(define CountSteps::note_lowest 0)
21
 
(define CountSteps::note_position 6)
22
 
(define CountSteps::userinput #t)
23
 
(define CountSteps::direction 0)
24
 
 
25
 
(define (CountSteps::showscore)
26
 
  (d-DirectivePut-score-display "CountSteps::GameScore" (string-append "&lt;b&gt;Score: " (object-&gt;string CountSteps::score) "&lt;/b&gt; in " (object-&gt;string (- CountSteps::end CountSteps::start)) " Secs.")))
27
 
 
28
 
(define (CountSteps::help) 
29
 
  (d-InfoDialog "Count how many steps it takes to get to the next note. Enter this number on they keyboard..... ")
30
 
)
31
 
 
32
 
(define (CountSteps::GameOver)
33
 
  (d-InfoDialog (string-append "Game Over\n" "Your Score = " (number->string CountSteps::score)))
34
 
)
35
 
 
36
 
(define (CountSteps::ScoreBoard)
37
 
    (d-InfoDialog (EducationGames::Scoreboard_Pretty_Print
38
 
          (EducationGames::ScoreboardFile "CountSteps")))
39
 
)
40
 
 
41
 
(CreateButton "CountSteps::GameScore" "&lt;span font_desc=\"12\"&gt;Score&lt;/span&gt;")
42
 
(d-SetDirectiveTagActionScript "CountSteps::GameScore" "(CountSteps::ScoreBoard)")
43
 
(CreateButton "CountSteps::GameHelp" "&lt;b&gt;Help&lt;/b&gt;")
44
 
(d-SetDirectiveTagActionScript "CountSteps::GameHelp" "(CountSteps::help)")
45
 
 
46
 
 
47
 
;;;;;;;; the main function to run the test - just goes to end and places a note at a random height above the cursor, returning the cursor to where it was.
48
 
(define (CountSteps::offerNote) 
49
 
  (let (
50
 
        (outofrange? 0)
51
 
        (seed 0)
52
 
        (steps 0)
53
 
        (position 0)
54
 
        )
55
 
        
56
 
        (set! outofrange?
57
 
          (lambda ()
58
 
            (or (> position CountSteps::note_highest) 
59
 
                (> CountSteps::note_lowest position)) 
60
 
                ))
61
 
        (set! seed 
62
 
          (lambda ()
63
 
            (set! steps (random CountSteps::interval))
64
 
            (if (= steps 0)
65
 
              (set! steps 1))
66
 
            (if (= (random 2) 0)
67
 
              (set! position (+ position steps))
68
 
              (set! position (- position steps)))
69
 
              (if (outofrange?)
70
 
                (begin
71
 
                  (set! position CountSteps::note_position)
72
 
                  (seed))
73
 
                (begin
74
 
                  (set! CountSteps::note_position position)))
75
 
              ))
76
 
  (if (>= CountSteps::num-goes 0)
77
 
    (begin
78
 
        (set! position CountSteps::note_position)
79
 
        (seed)
80
 
        ;;  (d-GoToEnd)
81
 
        (let gotoEnd () (if  (d-NextObject) (gotoEnd)))
82
 
 
83
 
        (d-CursorToNote (EducationalGames::middle_c_offset->lily CountSteps::note_position))
84
 
        (d-Insert2)
85
 
        (set! CountSteps::intervalwas steps)
86
 
           
87
 
        (CountSteps::showscore)
88
 
        (set! CountSteps::num-goes (-  CountSteps::num-goes 1))
89
 
        )) ;if
90
 
        ))
91
 
 
92
 
;;;;;;;;; callback when user chooses a note
93
 
(define (CountSteps::intervalchosen interval)
94
 
                      (begin
95
 
                        (set! CountSteps::end (current-time))
96
 
                        (let gotoEnd () (if  (d-NextObject) (gotoEnd))) 
97
 
                        (if  (= CountSteps::intervalwas interval)
98
 
                             (begin
99
 
                               (set! CountSteps::score (+ CountSteps::score 1))
100
 
                               (EducationGames::PlaceAnswerStatus "CheckMark"))
101
 
                             (begin
102
 
                               (set! CountSteps::score (- CountSteps::score 1))
103
 
                               (EducationGames::PlaceAnswerStatus "CrossSign"))) 
104
 
                               (CountSteps::offerNote)
105
 
                               ))
106
 
        
107
 
;;;;;;;; the main function to run the test
108
 
(define CountSteps::runtest 
109
 
        (lambda (n)
110
 
          (if (>= n 0) (begin
111
 
                        (set! CountSteps::userinput (EducationGames::GetAcceptableKeyInput CountSteps::acceptable_list))
112
 
                        (set! CountSteps::userinput 
113
 
                            (string-&gt;number CountSteps::userinput))
114
 
 
115
 
                        (CountSteps::intervalchosen CountSteps::userinput)      
116
 
                        (CountSteps::runtest CountSteps::num-goes)))))
117
 
 
118
 
                        
119
 
(define (CountSteps::plus)
120
 
  (set! CountSteps::interval (+ CountSteps::interval 1))
121
 
  (if (&gt; CountSteps::interval 9)
122
 
      (set! CountSteps::interval 9))
123
 
  (d-DirectivePut-score-display "CountSteps::GameInterval"
124
 
                                (string-append "&lt;span font_desc=\"12\"&gt;Interval: " (object-&gt;string CountSteps::interval) "&lt;/span&gt;")))
125
 
 
126
 
(define (CountSteps::minus)
127
 
  (set! CountSteps::interval (- CountSteps::interval 1))
128
 
  (if (&lt; CountSteps::interval 2)
129
 
      (set! CountSteps::interval 2))
130
 
  (d-DirectivePut-score-display "CountSteps::GameInterval"
131
 
                                (string-append "&lt;span font_desc=\"12\"&gt;Interval: " (object-&gt;string CountSteps::interval) "&lt;/span&gt;")))
132
 
 
133
 
(define (CountSteps::setInterval)
134
 
  (set! CountSteps::interval (string-&gt;number (d-GetUserInput "Interval" "Give number of steps you want to name note over" (object-&gt;string CountSteps::interval))))
135
 
  (if (boolean? CountSteps::interval)
136
 
       (set! CountSteps::interval 8))
137
 
  (if (&lt; CountSteps::interval 2)
138
 
       (set! CountSteps::interval 2))
139
 
  (if (&gt; CountSteps::interval 9)
140
 
      (set! CountSteps::interval 9))
141
 
  (d-DirectivePut-score-display "CountSteps::GameInterval"
142
 
                                (string-append "&lt;span font_desc=\"12\"&gt;Interval: " (object-&gt;string CountSteps::interval) "&lt;/span&gt;")))
143
 
 
144
 
 
145
 
(CreateButton "CountSteps::GameMinus" "&lt;b&gt;-&lt;/b&gt;")
146
 
(d-SetDirectiveTagActionScript "CountSteps::GameMinus" "(CountSteps::minus)")
147
 
(CreateButton "CountSteps::GameInterval" (string-append "&lt;span font_desc=\"12\"&gt;Interval: " (object-&gt;string CountSteps::interval) "&lt;/span&gt;"))
148
 
(d-SetDirectiveTagActionScript "CountSteps::GameInterval" "(CountSteps::setInterval)")
149
 
(CreateButton "CountSteps::GamePlus" "&lt;b&gt;+&lt;/b&gt;")
150
 
(d-SetDirectiveTagActionScript "CountSteps::GamePlus" "(CountSteps::plus)")
151
 
 
152
 
 
153
 
 
154
 
 
155
 
 
156
 
          
157
 
(EducationGames::Chime)
158
 
 
159
 
(d-CursorToNote (EducationalGames::middle_c_offset->lily CountSteps::note_position))
160
 
(d-Insert2)
161
 
(CountSteps::offerNote)
162
 
(set! CountSteps::start (current-time))
163
 
(CountSteps::runtest CountSteps::num-goes)
164
 
(if (not
165
 
  (EducationGames::Write_Scoreboard_File
166
 
  (EducationGames::ScoreboardFile "CountSteps") CountSteps::score))
167
 
  (CountSteps::GameOver)
168
 
  (CountSteps::ScoreBoard)
169
 
  )
170
 
 
171
 
(EducationGames::Chime)
172
 
  
173
 
;;;;;;;;;;;;;;;;;;;;;;;;;;
174
 
 
175
 
</scheme>
176
 
        <label>Step Counting Exercise</label>
177
 
        <tooltip>%tests your ability to find the number of diatonic notes between two notes</tooltip>
178
 
      </row>
179
 
    </map>
180
 
  </merge>
181
 
</Denemo>