module Tank ( Tank(..)
            , tankX
            , tankY
            ) where

import Vector

data Tank = Tank
          { tankPos           :: !Vertex
          , tankDir           :: !Rotation
          , tankAim           :: !Rotation
          , tankSpeed         :: !Coord
          , tankTurnspeed     :: !Coord
          , tankMoving        :: !Bool
          , tankBulletSpeed   :: !Coord
          , tankBulletBounces :: !Int
          , tankBulletsLeft   :: !Int
          , tankLife          :: !Int
          } deriving (Eq, Show)

tankX :: Tank -> Coord
tankX = vertexX . tankPos

tankY :: Tank -> Coord
tankY = vertexY . tankPos

instance Transformable Tank where
  transform t tank = tank { tankPos = pos , tankDir = dir, tankAim = aim } where
    pos = t >< tankPos tank
    dir = t >< tankDir tank
    aim = t >< tankAim tank