;; Data Def: ;; World is one of ;; -- false ;; -- positive number ;; Interpretation: ;; -- false means the rocket hasn't been launched ;; -- number n means the rocket has been launched and has reached height n ;; world-move : World -> World ;; move the world (define (world-move w) (cond [(boolean? w) (cond ;; NOTE: this anticipates unions [(odd? (random 100)) HEIGHT] [else false])] [(number? w) (- w 3)])) ;; up means smaller y coordinate!!! ;; world-draw : World -> World ;; draw the world Ü (define (world-draw w) (cond [(boolean? w) BLANK] [(number? w) (place-image (circle 3 'solid 'red) 20 w BLANK)])) (define WIDTH 100) (define HEIGHT 100) (define BLANK (empty-scene WIDTH HEIGHT)) ;; test (= (world-move 10) 7) ;; how could you test (world-move false) (image=? (world-draw false) BLANK) (image=? (world-draw 10) (place-image (circle 1 'solid 'red) 20 10 BLANK)) ;; run program run ;; tock : World -> World ;; update the canvas and produce next world (define (tock w) (update (world-draw w) produce (world-move w))) (big-bang WIDTH HEIGHT .1 false) (on-tick-event tock)