summaryrefslogtreecommitdiffstats
path: root/src/Tank.hs
blob: f3230f2e5932ae440f168f8fd9fd0ec48f8b327e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Tank ( Tank(..)
            , tankX
            , tankY
            ) where

import Transformable
import Vector

data Tank = Tank
          { tankPos           :: !Vertex
          , tankDir           :: !Vector
          , tankAim           :: !Vector
          , 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
  t >< tank = tank { tankPos = pos, tankDir = dir, tankAim = aim } where
    pos = t >< tankPos tank
    dir = t >< tankDir tank
    aim = t >< tankAim tank