restructuring

This commit is contained in:
nek0 2021-01-19 21:46:17 +01:00
parent 3d9af3eaf8
commit ae38902d9c
1 changed files with 24 additions and 26 deletions

View File

@ -91,11 +91,7 @@ instance Actor Pituicat where
lerp (min 0.95 (59 * dt)) (pcMoveVel physCat) (pcTMoveVel physCat)
}
in
(A.log Debug (
("being at " <> fromString (show $ position finalCat)) <>
("; moving with " <> fromString (show $ velocity finalCat))
)
) finalCat
finalCat
instance Mass Pituicat where
@ -145,24 +141,26 @@ instance Collidible Pituicat where
collide cat _ NoCollision = cat
collide cat other collr@(Collision ddt (V2 dirx diry)) =
A.log
Debug
("*boing* meow! other: " <>
fromString (show other))
(
let ncat = (elasticCollision 0.3 cat other collr)
nvel@(V2 dx dy) =
velocity ncat *
if dirx == 0
then V2 0 1
else V2 1 1
grounded = (dy * ddt) <= 0 && (dy * ddt) > (-2) && diry == 0
in
ncat
{ pcGrounded = grounded
, pcMoveVel = pcMoveVel ncat *
if dirx == 0
then V2 0 1
else V2 1 1
}
)
let ncat = (elasticCollision 0.3 cat other collr)
vel@(V2 vx vy) = velocity cat
nvel@(V2 dx dy) = velocity ncat
grounded =
(dy * ddt) >= 0 &&
(dy * ddt) < 2 && diry == -1
in
A.log
Debug
("*boing* meow! collision result: " <>
fromString (show collr) <>
"\nother: " <>
fromString (show other)
)
(
ncat
{ pcGrounded = grounded
, pcMoveVel = pcMoveVel ncat *
if dirx /= 0
then V2 0 1
else V2 1 1
}
)