This file contains 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
type GameCommand = | |
| MoveLeft | MoveRight | |
| MoveUp | MoveDown | |
| MoveUpLeft | MoveUpRight | |
| MoveDownLeft | MoveDownRight | |
| Wait | |
| Restart | |
let playTurn state player getRandomNumber command = | |
let world = state.World | |
match command with | |
| MoveLeft -> { state with World = moveActor world player -1 0 } | |
| MoveRight -> { state with World = moveActor world player 1 0 } | |
| MoveUp -> { state with World = moveActor world player 0 -1 } | |
| MoveDown -> { state with World = moveActor world player 0 1 } | |
| MoveUpLeft -> { state with World = moveActor world player -1 -1 } | |
| MoveUpRight -> { state with World = moveActor world player 1 -1 } | |
| MoveDownLeft -> { state with World = moveActor world player -1 1 } | |
| MoveDownRight -> { state with World = moveActor world player 1 1 } | |
| Wait -> | |
printfn "Time Passes..." | |
state | |
| Restart -> | |
let world = makeWorld 13 13 getRandomNumber | |
{ World = world; Player = world.Squirrel } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment