introduce and propagate view direction
This commit is contained in:
parent
58ae21724b
commit
2e25c4cfcc
3 changed files with 37 additions and 19 deletions
|
@ -25,6 +25,13 @@ singleHandler level event = do
|
||||||
changeDirection cat state =
|
changeDirection cat state =
|
||||||
Just cat
|
Just cat
|
||||||
{ pcMoveState = if multiplier > 0 then Just state else Nothing
|
{ pcMoveState = if multiplier > 0 then Just state else Nothing
|
||||||
|
, pcViewDirection = if multiplier > 0 && pcGrounded cat
|
||||||
|
then
|
||||||
|
if state == MoveRight
|
||||||
|
then ViewRight
|
||||||
|
else ViewLeft
|
||||||
|
else
|
||||||
|
pcViewDirection cat
|
||||||
}
|
}
|
||||||
liftIO $ atomically $ modifyTVar (testPlayer level) (\(Just pituicat) ->
|
liftIO $ atomically $ modifyTVar (testPlayer level) (\(Just pituicat) ->
|
||||||
A.log Debug ("Grounded: " <> fromString (show $ pcGrounded pituicat)) $
|
A.log Debug ("Grounded: " <> fromString (show $ pcGrounded pituicat)) $
|
||||||
|
|
|
@ -82,6 +82,7 @@ load level progress = do
|
||||||
tex
|
tex
|
||||||
False
|
False
|
||||||
Nothing
|
Nothing
|
||||||
|
ViewRight
|
||||||
[]
|
[]
|
||||||
oil = PowerUp
|
oil = PowerUp
|
||||||
(realToFrac <$> (startpos + V2 200 0))
|
(realToFrac <$> (startpos + V2 200 0))
|
||||||
|
|
|
@ -30,28 +30,32 @@ catMoveVelocity :: Double
|
||||||
catMoveVelocity = 100
|
catMoveVelocity = 100
|
||||||
|
|
||||||
data Pituicat = Pituicat
|
data Pituicat = Pituicat
|
||||||
{ pcPos :: V2 Double
|
{ pcPos :: V2 Double
|
||||||
, pcVel :: V2 Double
|
, pcVel :: V2 Double
|
||||||
, pcMoveVel :: V2 Double
|
, pcMoveVel :: V2 Double
|
||||||
, pcTMoveVel :: V2 Double
|
, pcTMoveVel :: V2 Double
|
||||||
, pcAcc :: V2 Double
|
, pcAcc :: V2 Double
|
||||||
, pcHealth :: Int
|
, pcHealth :: Int
|
||||||
, pcTexture :: Texture
|
, pcTexture :: Texture
|
||||||
, pcGrounded :: Bool
|
, pcGrounded :: Bool
|
||||||
, pcMoveState :: Maybe Action
|
, pcMoveState :: Maybe Action
|
||||||
, pcEffects :: [EffectHolder]
|
, pcViewDirection :: ViewDirection
|
||||||
|
, pcEffects :: [EffectHolder]
|
||||||
}
|
}
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
data ViewDirection = ViewLeft | ViewRight
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
instance Drawable Pituicat where
|
instance Drawable Pituicat where
|
||||||
|
|
||||||
toVertices (Pituicat (V2 x y) _ (V2 mx _) _ _ _ _ _ _ _) =
|
toVertices (Pituicat (V2 x y) _ _ _ _ _ _ _ _ vd _) =
|
||||||
( V.fromList [0, 1, 2, 2, 3, 0]
|
( V.fromList [0, 1, 2, 2, 3, 0]
|
||||||
, V.fromList
|
, V.fromList
|
||||||
[ newVertex
|
[ newVertex
|
||||||
(V3 (realToFrac x - 25) (realToFrac y - 25) 0)
|
(V3 (realToFrac x - 25) (realToFrac y - 25) 0)
|
||||||
(V4 1 1 1 1)
|
(V4 1 1 1 1)
|
||||||
(if mx >= 0
|
(if vd == ViewRight
|
||||||
then V2 0 (1 - 50 / 1024)
|
then V2 0 (1 - 50 / 1024)
|
||||||
else V2 (50 / 1024) (1 - 50 / 1024)
|
else V2 (50 / 1024) (1 - 50 / 1024)
|
||||||
)
|
)
|
||||||
|
@ -59,7 +63,7 @@ instance Drawable Pituicat where
|
||||||
, newVertex
|
, newVertex
|
||||||
(V3 (realToFrac x + 25) (realToFrac y - 25) 0)
|
(V3 (realToFrac x + 25) (realToFrac y - 25) 0)
|
||||||
(V4 1 1 1 1)
|
(V4 1 1 1 1)
|
||||||
( if mx >= 0
|
(if vd == ViewRight
|
||||||
then V2 (50 / 1024) (1 - 50 / 1024)
|
then V2 (50 / 1024) (1 - 50 / 1024)
|
||||||
else V2 0 (1 - 50 / 1024)
|
else V2 0 (1 - 50 / 1024)
|
||||||
)
|
)
|
||||||
|
@ -67,7 +71,7 @@ instance Drawable Pituicat where
|
||||||
, newVertex
|
, newVertex
|
||||||
(V3 (realToFrac x + 25) (realToFrac y + 25) 0)
|
(V3 (realToFrac x + 25) (realToFrac y + 25) 0)
|
||||||
(V4 1 1 1 1)
|
(V4 1 1 1 1)
|
||||||
(if mx >= 0
|
(if vd == ViewRight
|
||||||
then V2 (50 / 1024) 1
|
then V2 (50 / 1024) 1
|
||||||
else V2 0 1
|
else V2 0 1
|
||||||
)
|
)
|
||||||
|
@ -75,7 +79,7 @@ instance Drawable Pituicat where
|
||||||
, newVertex
|
, newVertex
|
||||||
(V3 (realToFrac x - 25) (realToFrac y + 25) 0)
|
(V3 (realToFrac x - 25) (realToFrac y + 25) 0)
|
||||||
(V4 1 1 1 1)
|
(V4 1 1 1 1)
|
||||||
(if mx >= 0
|
(if vd == ViewRight
|
||||||
then V2 0 1
|
then V2 0 1
|
||||||
else V2 (50 / 1024) 1
|
else V2 (50 / 1024) 1
|
||||||
)
|
)
|
||||||
|
@ -174,10 +178,16 @@ instance Mass Pituicat where
|
||||||
|
|
||||||
instance Collidible Pituicat where
|
instance Collidible Pituicat where
|
||||||
|
|
||||||
boundary _ =
|
boundary cat =
|
||||||
( V2 (-18) (-25)
|
if pcViewDirection cat == ViewRight
|
||||||
, V2 25 15
|
then
|
||||||
)
|
( V2 (-18) (-25)
|
||||||
|
, V2 25 15
|
||||||
|
)
|
||||||
|
else
|
||||||
|
( V2 (-25) (-25)
|
||||||
|
, V2 18 15
|
||||||
|
)
|
||||||
|
|
||||||
collide cat _ NoCollision = cat
|
collide cat _ NoCollision = cat
|
||||||
collide cat other collr@(Collision ddt (V2 dirx diry)) =
|
collide cat other collr@(Collision ddt (V2 dirx diry)) =
|
||||||
|
|
Loading…
Reference in a new issue