Added Transformable class to simplify collision calculation
This commit is contained in:
parent
d7971385e8
commit
83f0606ea9
13 changed files with 258 additions and 144 deletions
|
@ -10,6 +10,7 @@ import Player
|
|||
import Tank
|
||||
import Texture
|
||||
import Model
|
||||
import qualified Vector as V
|
||||
|
||||
import Control.Monad.State
|
||||
|
||||
|
@ -148,11 +149,11 @@ render = do
|
|||
forM_ tanklist $ \tank -> unsafePreservingMatrix $ do
|
||||
let x = realToFrac . tankX $ tank
|
||||
y = realToFrac . tankY $ tank
|
||||
rotDir = realToFrac . tankDir $ tank
|
||||
rotAim = realToFrac . tankAim $ tank
|
||||
rotDir = realToFrac . V.toAngle . tankDir $ tank
|
||||
rotAim = realToFrac . V.toAngle . tankAim $ tank
|
||||
|
||||
translate $ Vector3 x y (0 :: GLfloat)
|
||||
rotate rotDir $ Vector3 0 0 (1 :: GLfloat)
|
||||
rotate (rotDir*180/pi) $ Vector3 0 0 (1 :: GLfloat)
|
||||
|
||||
textureBinding Texture2D $= Just textureTank
|
||||
|
||||
|
@ -160,7 +161,7 @@ render = do
|
|||
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
|
||||
drawObject modelTank 1
|
||||
|
||||
rotate (rotAim-rotDir) $ Vector3 0 0 (1 :: GLfloat)
|
||||
rotate ((rotAim-rotDir)*180/pi) $ Vector3 0 0 (1 :: GLfloat)
|
||||
|
||||
textureBinding Texture2D $= Just textureCannon
|
||||
|
||||
|
@ -174,10 +175,10 @@ render = do
|
|||
forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do
|
||||
let x = realToFrac . bulletX $ bullet
|
||||
y = realToFrac . bulletY $ bullet
|
||||
rotDir = realToFrac . bulletDir $ bullet
|
||||
rotDir = realToFrac . V.toAngle . bulletDir $ bullet
|
||||
|
||||
translate $ Vector3 x y (0.25 :: GLfloat)
|
||||
rotate (rotDir-90) $ Vector3 0 0 (1 :: GLfloat)
|
||||
rotate ((rotDir*180/pi)-90) $ Vector3 0 0 (1 :: GLfloat)
|
||||
|
||||
unsafePreservingMatrix $ do
|
||||
drawObject modelBullet 0
|
||||
|
|
Reference in a new issue