From ae38902d9c2c04e6004f6f4bd22afeee9cf48bb5 Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 19 Jan 2021 21:46:17 +0100 Subject: [PATCH] restructuring --- src/Types/Player.hs | 50 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/Types/Player.hs b/src/Types/Player.hs index cd12e97..31a2521 100644 --- a/src/Types/Player.hs +++ b/src/Types/Player.hs @@ -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 + } + )