summaryrefslogtreecommitdiffstats
path: root/src/Tank.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-24 21:50:32 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-24 21:50:32 +0200
commit83f0606ea9dfd6b493097dc97330055dff4a2867 (patch)
tree464d7f3ed2c02f48b6463d1528e3e0b5f50e79c6 /src/Tank.hs
parentd7971385e844e24d9d851d3d142895b5cb89c91b (diff)
downloadhtanks-83f0606ea9dfd6b493097dc97330055dff4a2867.tar
htanks-83f0606ea9dfd6b493097dc97330055dff4a2867.zip
Added Transformable class to simplify collision calculation
Diffstat (limited to 'src/Tank.hs')
-rw-r--r--src/Tank.hs30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/Tank.hs b/src/Tank.hs
index 2fbf612..f3230f2 100644
--- a/src/Tank.hs
+++ b/src/Tank.hs
@@ -1,18 +1,32 @@
module Tank ( Tank(..)
+ , tankX
+ , tankY
) where
-import Data.Fixed
+import Transformable
+import Vector
data Tank = Tank
- { tankX :: !Micro
- , tankY :: !Micro
- , tankDir :: !Micro
- , tankAim :: !Micro
- , tankSpeed :: !Micro
- , tankTurnspeed :: !Micro
+ { tankPos :: !Vertex
+ , tankDir :: !Vector
+ , tankAim :: !Vector
+ , tankSpeed :: !Coord
+ , tankTurnspeed :: !Coord
, tankMoving :: !Bool
- , tankBulletSpeed :: !Micro
+ , 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 \ No newline at end of file