summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-03-08 22:32:52 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-03-08 22:32:52 +0100
commit907cb95dae83a25dabf377228f4d70a1cab3216f (patch)
tree56a0e6429ecd673ec00ff1a59bbad54fb27dd6fd
parent335c10654f7d41053ffcabed19cb003d1c0ce13e (diff)
downloadhtanks-907cb95dae83a25dabf377228f4d70a1cab3216f.tar
htanks-907cb95dae83a25dabf377228f4d70a1cab3216f.zip
Shooting is possible now
-rw-r--r--HTanks.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/HTanks.hs b/HTanks.hs
index 7c648c1..ace90d3 100644
--- a/HTanks.hs
+++ b/HTanks.hs
@@ -160,14 +160,23 @@ simulationStep = do
oldplayers <- gets players
oldtanks <- lift $ gets tanks
- let pt = unzip $ map updateTank' $ zip oldplayers oldtanks
-
- modify $ \state -> state {players = fst pt}
- lift $ modify $ \state -> state {tanks = snd pt, shoots = map (execState updateShoot) $ shoots state}
+ let (p, t, s) = unzip3 $ map updateTank' $ zip oldplayers oldtanks
+ shootingtanks = map fst $ filter snd $ zip t s
+ newshoots = map (\tank -> Shoot
+ {shootX = posx tank
+ , shootY = posy tank
+ , shootDir = aim tank
+ , shootSpeed = tankShootSpeed tank
+ , bouncesLeft = tankShootBounces tank
+ }) shootingtanks
+
+
+ modify $ \state -> state {players = p}
+ lift $ modify $ \state -> state {tanks = t, shoots = map (execState updateShoot) (shoots state ++ newshoots)}
where
updateTank' (player, tank) = let (p, angle, move, aangle, shoot) = playerUpdate player tank
t = execState (updateTank angle move aangle) tank
- in (p, t)
+ in (p, t, shoot)
handleEvents :: Main ()