Advertisement
Guest User

Untitled

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