Last active
September 25, 2016 04:26
-
-
Save yuanw/6a7457a4e924faba6acf085837a27c36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE OverloadedStrings #-} | |
| import CodeWorld | |
| botCircle c = colored c (translated 0 (-1.5) (solidCircle 1)) | |
| middleCircle c = colored c (translated 0 1.5 (solidCircle 1)) | |
| topCircle c = colored c (translated 0 4.5 (solidCircle 1)) | |
| frame = rectangle 2.5 12.0 | |
| trafficLight 0 = botCircle green & middleCircle black & topCircle black & frame | |
| trafficLight 1 = botCircle black & middleCircle yellow & topCircle black & frame | |
| trafficLight 2 = botCircle black & middleCircle black & topCircle red & frame | |
| trafficLight 3 = botCircle black & middleCircle yellow & topCircle red & frame | |
| trafficController :: Double -> Picture | |
| trafficController t = trafficLight ( round (t/3) `mod` 4) | |
| main :: IO () | |
| main = animationOf trafficController |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment