Hello,
I have this programm :
; WorldState -> WorldState
; the clock ticked; decrease the gauge with 0.1
; example:
; given: 20, expected 19.9
; given: 78, expected 77.9
(define (tock ws)
(if (> ws 0) (- ws 0.1)0 ))
; GaugeState -> Gaugestate.
; display the gauge.
(define (gauge ws)
(overlay/xy (rectangle 100 20 "outline" "black") 0 0 (rectangle ws 20 "solid" "red")))
; World -> World
; adjust the gauge when the user uses the up or down key.
; given 20 and the down-key expected 20.5
; given 78 and the up-key expected 78,3
(define (toets ws input)
(cond
[ (key=? input "down") (+ ws 0.3)]
[ (key=? input "up") (+ ws 0.5)]
[ else ws]
))
(define (main ws)
(big-bang ws (on-tick tock) (to-draw gauge) (on-key toets)))
It runs perfectly but do I understand it right that the variable ws is the same as world.
Roelof
I have this programm :
; WorldState -> WorldState
; the clock ticked; decrease the gauge with 0.1
; example:
; given: 20, expected 19.9
; given: 78, expected 77.9
(define (tock ws)
(if (> ws 0) (- ws 0.1)0 ))
; GaugeState -> Gaugestate.
; display the gauge.
(define (gauge ws)
(overlay/xy (rectangle 100 20 "outline" "black") 0 0 (rectangle ws 20 "solid" "red")))
; World -> World
; adjust the gauge when the user uses the up or down key.
; given 20 and the down-key expected 20.5
; given 78 and the up-key expected 78,3
(define (toets ws input)
(cond
[ (key=? input "down") (+ ws 0.3)]
[ (key=? input "up") (+ ws 0.5)]
[ else ws]
))
(define (main ws)
(big-bang ws (on-tick tock) (to-draw gauge) (on-key toets)))
It runs perfectly but do I understand it right that the variable ws is the same as world.
Roelof
____________________ Racket Users list: http://lists.racket-lang.org/users