Created
May 12, 2020 13:23
-
-
Save tarquin-the-brave/f05a70ca102ace1c436e7ccd726e99c0 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
| data LiveData = LiveData { | |
| -- x-coordinate of the ball - xb | |
| xb::Int, | |
| -- x-coordinate of the paddle - xp | |
| xp::Int, | |
| -- Game score - sc | |
| sc::Int | |
| } deriving(Show) | |
| stepGame' :: [Int] -> Game -> (LiveData, Game) | |
| stepGame :: [Int] -> State Game LiveData | |
| stepGame = state . stepGame' | |
| playGame :: [Int] -> State Game Int | |
| playGame inp = do | |
| liveData <- stepGame inp | |
| game <- get | |
| case IC.progState (gameProg game) of | |
| IC.AwaitInput -> playGame [joystick (xb liveData) (xp liveData)] | |
| _ -> return $ sc liveData | |
| joystick :: Int -> Int -> Int |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment