Created
January 5, 2014 09:59
-
-
Save anonymous/8266470 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
module Entities where | |
data Point = TwoD Int Int | ThreeD Int Int Int | |
class Entity a where | |
pos :: a -> Point | |
speed :: a -> Int | |
id :: a -> String | |
alive :: a -> Bool | |
data TurretTpl = TurretTpl { | |
tViewAngle :: Int | |
, tTurnSpeed :: Int | |
} | |
data Turret = Turret { | |
tAzimuth :: Int | |
, tpl :: Int | |
} | |
data TankTpl = TankTpl { | |
tMaxSpeed :: Int | |
, tMaxHP :: Int | |
, tTurretTpl :: TurretTpl | |
} | |
data Tank = Tank { | |
tName :: String | |
, tPos :: Point | |
, tSpeed :: Int | |
, tHP :: Int | |
, tTurret :: Turret | |
} | |
instance Entity Tank where | |
pos = tPos | |
speed = tSpeed | |
id = tName | |
alive t = tHP t > 0 | |
data Polygon = Polygon [Point] | |
data Terrain = Terrain [Polygon] | |
class Agent a where | |
iterate :: a -> Terrain -> [(Tank, TankTpl)] -> [(Tank, TankTpl)] | |
data World = World { | |
wTerrain :: Terrain | |
, wTanks :: [(Agent x, [(Tank, TankTpl)])] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment