diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-26 20:55:51 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-26 20:55:51 +0200 |
commit | cc53496bab9ad2bbfc3fb2868cd10fa46f612e69 (patch) | |
tree | f974028160c90e5a373c3ac38d8d7229c419aaa7 /src/HWiidPlayer.hs | |
parent | 8f1fd98cd69659446b9fdd11c0f3d2b860d779f7 (diff) | |
download | htanks-cc53496bab9ad2bbfc3fb2868cd10fa46f612e69.tar htanks-cc53496bab9ad2bbfc3fb2868cd10fa46f612e69.zip |
Reworked Transform as a type class
Diffstat (limited to 'src/HWiidPlayer.hs')
-rw-r--r-- | src/HWiidPlayer.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/HWiidPlayer.hs b/src/HWiidPlayer.hs index d98b9c9..9517394 100644 --- a/src/HWiidPlayer.hs +++ b/src/HWiidPlayer.hs @@ -55,11 +55,11 @@ instance Player HWiidPlayer where (aimx, aimy) = if null aims then (0, 0) else mulV (1/(fromIntegral $ length aims)) (foldr addV (0, 0) aims) ax = realToFrac $ aimx - (fromRational . toRational . tankX $ tank) ay = realToFrac $ aimy - (fromRational . toRational . tankY $ tank) - aim = if (ax /= 0 || ay /= 0) then Just $ V.Vector ax ay else Nothing + aim = if (ax /= 0 || ay /= 0) then Just . V.fromVector $ V.Vector ax ay else Nothing move = (mx /= 0 || my /= 0) angle = atan2 my mx - dir = if move then Just $ T.rotate (fromRational $ round ((angle - (sin $ 8*x)/8)*1000000*180/pi)%1000000) T.>< V.Vector 1 0 else Nothing + dir = if move then Just $ V.fromAngle (fromRational $ round ((angle - (sin $ 8*x)/8)*1000000)%1000000) else Nothing when foo $ print state return (HWiidPlayer wiimote cal aims, dir, move, aim, shoot) |