From bbc4e34213147f30068a00bb56ebb871114e26dd Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Tue, 31 Dec 2024 17:02:00 -0800 Subject: Tweaks. --- Demos/Pong/Pong.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Demos/Pong') diff --git a/Demos/Pong/Pong.hs b/Demos/Pong/Pong.hs index 790a98e..f1b3c74 100644 --- a/Demos/Pong/Pong.hs +++ b/Demos/Pong/Pong.hs @@ -56,6 +56,7 @@ data GameObject = GameObject { gameObjectId :: !GameObjectId , gameObjectSize :: {-# UNPACK #-} !Vector2 , basis :: {-# UNPACK #-} !Transform2 + -- TODO: Think about storing steppers separately. , gostep :: Step [GameObject] [GameEvent] GameObject GameObject } @@ -121,7 +122,7 @@ update elapsed dt events gos go = -- Ball steppers -stepBall vel = bounceBall vel .> moveBall +stepBall vel = bounceBall vel .> moveBall -- .> clamp bounceBall :: Vector2 -> Step [GameObject] [GameEvent] GameObject (Vector2, GameObject) bounceBall vel = step $ \_ dt gos events ball -> @@ -192,11 +193,11 @@ movePlayer' dir = step $ \_ dt _ _ go -> (translate (dir * dt) go, movePlayer' d clamp :: Step s e GameObject GameObject clamp = spure $ \go -> - let p' = vec2 (clamp' x s (1 - s)) y + let p' = vec2 (clamp' x sx (1 - sx)) y (Vector2 x y) = position go clamp' x a b | x < a = a | x > b = b | otherwise = x - (Vector2 s _) = padSize + (Vector2 sx _) = gameObjectSize go in setPosition p' go -- cgit v1.2.3