Advertisement
Guest User

Untitled

a guest
Jan 7th, 2019
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. ;constants
  2. (define background (empty-scene 450 150))
  3. (define red (place-image
  4. (overlay/offset
  5. (overlay/offset (overlay
  6. (circle 65 255 "white")
  7. (circle 70 255 "green"))
  8. -145 0
  9. (overlay
  10. (circle 65 255 "white")
  11. (circle 70 255 "yellow")))
  12. -217 0 (circle 70 255 "red")) 225 75 background))
  13. (define yellow (place-image
  14. (overlay/offset
  15. (overlay/offset (overlay
  16. (circle 65 255 "white")
  17. (circle 70 255 "green"))
  18. -145 0
  19. (circle 70 255 "yellow"))
  20. -217 0 (overlay (circle 65 255 "white")
  21. (circle 70 255 "red"))) 225 75 background))
  22. (define green (place-image
  23. (overlay/offset
  24. (overlay/offset
  25. (circle 70 255 "green")
  26. -145 0
  27. (overlay (circle 65 255 "white")
  28. (circle 70 255 "yellow")))
  29. -217 0 (overlay (circle 65 255 "white")
  30. (circle 70 255 "red"))) 225 75 background))
  31. (define (tl-render x)
  32. (cond
  33. [(string=? "green" x) red]
  34. [(string=? "red" x) yellow]
  35. [(string=? "yellow" x) green]))
  36. (define (tl-next x)
  37. (cond
  38. [(string=? "green" x) "red"]
  39. [(string=? "red" x) "yellow"]
  40. [(string=? "yellow" x) "green"]))
  41. ;functions
  42. (define (traffic-light-simulation initial-state)
  43. (big-bang initial-state
  44. [to-draw tl-render]
  45. [on-tick tl-next 1]))
  46. (traffic-light-simulation "green")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement