Last active
December 30, 2016 14:01
-
-
Save b00gizm/1bb208110f524496a54e61dd63e323b2 to your computer and use it in GitHub Desktop.
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
import Html exposing (text) | |
type alias Energy = Int | |
type alias Position = { x: Int, y: Int } | |
type alias GameObject = { pos: Position, kind: Kind } | |
type Kind = Lifeform Energy | Obstacle | |
moveTo: GameObject -> Position -> GameObject | |
moveTo obj newPos = | |
case obj.kind of | |
Lifeform eng -> { obj | pos = newPos } | |
Obstacle -> obj | |
player: GameObject | |
player = | |
{ pos = { x = 0, y = 0 } | |
, kind = Lifeform 100 | |
} | |
main = | |
text (toString (moveTo player { x = 1, y = 1 })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment