Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;constants
- (define background (empty-scene 450 150))
- (define red (place-image
- (overlay/offset
- (overlay/offset (overlay
- (circle 65 255 "white")
- (circle 70 255 "green"))
- -145 0
- (overlay
- (circle 65 255 "white")
- (circle 70 255 "yellow")))
- -217 0 (circle 70 255 "red")) 225 75 background))
- (define yellow (place-image
- (overlay/offset
- (overlay/offset (overlay
- (circle 65 255 "white")
- (circle 70 255 "green"))
- -145 0
- (circle 70 255 "yellow"))
- -217 0 (overlay (circle 65 255 "white")
- (circle 70 255 "red"))) 225 75 background))
- (define green (place-image
- (overlay/offset
- (overlay/offset
- (circle 70 255 "green")
- -145 0
- (overlay (circle 65 255 "white")
- (circle 70 255 "yellow")))
- -217 0 (overlay (circle 65 255 "white")
- (circle 70 255 "red"))) 225 75 background))
- (define (tl-render x)
- (cond
- [(string=? "green" x) red]
- [(string=? "red" x) yellow]
- [(string=? "yellow" x) green]))
- (define (tl-next x)
- (cond
- [(string=? "green" x) "red"]
- [(string=? "red" x) "yellow"]
- [(string=? "yellow" x) "green"]))
- ;functions
- (define (traffic-light-simulation initial-state)
- (big-bang initial-state
- [to-draw tl-render]
- [on-tick tl-next 1]))
- (traffic-light-simulation "green")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement