world with lang scheme
svn: r10331
This commit is contained in:
parent
420263b569
commit
55604117e4
|
@ -2,25 +2,19 @@
|
|||
;; about the language level of this file in a form that our tools can easily process.
|
||||
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname world) (read-case-sensitive #t) (teachpacks ((lib "world.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "world.ss" "teachpack" "htdp")))))
|
||||
;; testing world
|
||||
|
||||
;; World = Nat
|
||||
|
||||
(define world0 10)
|
||||
(define world0 100)
|
||||
|
||||
(define (world->image w)
|
||||
(place-image (circle 3 'solid 'red)
|
||||
50 w
|
||||
(empty-scene 100 100)))
|
||||
(place-image (circle 3 'solid 'red) 50 w (empty-scene 100 100)))
|
||||
|
||||
(define (world->next w)
|
||||
(if (>= (+ w 3) 100)
|
||||
100
|
||||
(+ w 1)))
|
||||
(define (world->next w) (sub1 w))
|
||||
|
||||
(define (world->steer w ke)
|
||||
(cond
|
||||
[(char? ke) w]
|
||||
[(symbol=? ke 'left) 10]
|
||||
[(symbol=? ke 'left) 100]
|
||||
[(symbol=? ke 'right) 90]
|
||||
[else w]))
|
||||
|
||||
|
@ -31,4 +25,4 @@
|
|||
(on-redraw world->image)
|
||||
(on-tick-event world->next)
|
||||
(on-key-event world->steer)
|
||||
(is-end-of-world (lambda (w) (= w 100)))
|
||||
(stop-when zero?)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user