Skip to content

Instantly share code, notes, and snippets.

@b00gizm
Last active December 30, 2016 14:01
Show Gist options
  • Save b00gizm/1bb208110f524496a54e61dd63e323b2 to your computer and use it in GitHub Desktop.
Save b00gizm/1bb208110f524496a54e61dd63e323b2 to your computer and use it in GitHub Desktop.
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