From 6a4c0e5b428a7018277f36fff9a0d44d4ff05b2d Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 12 Jan 2021 00:53:00 +0100 Subject: [PATCH] adjust gravitation and jump --- src/Scenes/Test/EventHandler.hs | 2 +- src/Types/Player.hs | 8 +++++--- src/Util.hs | 8 +++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Scenes/Test/EventHandler.hs b/src/Scenes/Test/EventHandler.hs index 3d37c4d..afb96a9 100644 --- a/src/Scenes/Test/EventHandler.hs +++ b/src/Scenes/Test/EventHandler.hs @@ -28,7 +28,7 @@ singleHandler level event = do Jump -> if multiplier > 0 && pcGrounded pituicat then A.log Debug "jumping" (Just pituicat - { pcVel = pcVel pituicat + V2 0 250 + { pcVel = pcVel pituicat + V2 0 300 , pcGrounded = False } ) diff --git a/src/Types/Player.hs b/src/Types/Player.hs index 316af45..91f063a 100644 --- a/src/Types/Player.hs +++ b/src/Types/Player.hs @@ -11,6 +11,8 @@ import Data.String (fromString) -- internal imports +import Util + import Classes.Graphics.Drawable import Classes.Graphics.Bindable import Classes.Prop @@ -67,11 +69,11 @@ instance Prop Pituicat where instance Actor Pituicat where perform dt p = - let physCat = (accelerate dt . gravitate (V2 0 (-250))) + let physCat = (accelerate dt . gravitate constG) (p {pcAcc = 0}) (V2 _ dy) = pcVel physCat finalCat = physCat - { pcGrounded = pcGrounded physCat || (dy < 0 && abs dy < 1) + { pcGrounded = pcGrounded physCat || (dy < 0 && abs dy < 2) } in (A.log Debug ("moving with " <> fromString (show $ pcVel finalCat))) finalCat @@ -120,6 +122,6 @@ instance Collidible Pituicat where (V2 _ dy) = pcVel ncat in ncat - { pcGrounded = dy > 0 && abs dy < 1 + { pcGrounded = dy > 0 && abs dy < 2 } ) diff --git a/src/Util.hs b/src/Util.hs index 43d6bac..4ce0b88 100644 --- a/src/Util.hs +++ b/src/Util.hs @@ -5,9 +5,12 @@ import Affection import qualified SDL import qualified SDL.Internal.Numbered as SDL +import Linear + -- internal imports -import Types +import Types.Application +import Types.Subsystems globalKeyHandle :: GameData @@ -27,3 +30,6 @@ globalKeyHandle gd mesg@(MsgKeyboardEvent time win motion repeat keysym) = else return () _ -> return () + +constG :: V2 Double +constG = V2 0 (-500)