blob: c97b5de1d00ff2f24d195d07e59310c972694a25 (
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
33
34
35
36
37
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Game ( Bullet(..)
, bulletX
, bulletY
, GameState(..)
) where
import Level
import Tank
import Vector
data Bullet = Bullet
{ bulletPos :: !Vertex
, bulletDir :: !Rotation
, bulletSpeed :: !Coord
, bulletBouncesLeft :: !Int
, bulletTank :: !Int
} deriving (Eq, Show)
bulletX :: Bullet -> Coord
bulletX = vertexX . bulletPos
bulletY :: Bullet -> Coord
bulletY = vertexY . bulletPos
instance Transformable Bullet where
transform t b = b { bulletPos = pos, bulletDir = dir } where
pos = t >< bulletPos b
dir = t >< bulletDir b
data GameState = GameState
{ level :: !Level
, tanks :: ![Tank]
, bullets :: ![Bullet]
} deriving (Show)
|