From fd8d1268d2f347bb56400ac3f16f48dc7c22d1b0 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Tue, 20 Aug 2024 18:53:46 -0700 Subject: Tidy. --- Demos/Pong/Main.hs | 17 ++++++++--------- Demos/Pong/Pong.hs | 17 +++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Demos/Pong/Main.hs b/Demos/Pong/Main.hs index ee55622..c863a55 100644 --- a/Demos/Pong/Main.hs +++ b/Demos/Pong/Main.hs @@ -53,6 +53,14 @@ step elapsed dt inputEvents = do } return (not $ exitRequested inputEvents) +processInput :: Window -> Game GameState [GameEvent] +processInput window = processKeys window + [ (KEY_A, MoveLeft) + , (KEY_D, MoveRight) + ] + +exitRequested = elem (KeyDown KEY_ESC) + render :: Game GameState () render = do gameState <- getGameState @@ -113,12 +121,3 @@ resize (ResizeEvent w h) = modifyGameState $ \state -> state { viewProjection = Matrix4.ortho left right bottom top (-1) 1 } - - -processInput :: Window -> Game GameState [GameEvent] -processInput window = processKeys window - [ (KEY_A, MoveLeft) - , (KEY_D, MoveRight) - ] - -exitRequested = elem (KeyDown KEY_ESC) diff --git a/Demos/Pong/Pong.hs b/Demos/Pong/Pong.hs index 2bd9df1..e834c5d 100644 --- a/Demos/Pong/Pong.hs +++ b/Demos/Pong/Pong.hs @@ -77,14 +77,6 @@ instance Spatial GameObject Vector2 Angle Transform2 where transform = basis -stepWorld :: Elapsed -> Dt -> [GameEvent] -> [GameObject] -> [GameObject] -stepWorld elapsed dt evts gos = map (update elapsed dt evts gos) gos - -update :: Elapsed -> Dt -> [GameEvent] -> [GameObject] -> GameObject -> GameObject -update elapsed dt evts gos go = - let (go', s') = runStep (gostep go) elapsed dt gos evts go - in go' {gostep = s'} - ballBox, padBox :: AABB2 ballBox = AABB2 (vec2 (-s) (-s)) (vec2 s s) where s = ballSize padBox = AABB2 (-padSize) padSize @@ -96,6 +88,15 @@ newWorld = ] where makeAt = newTransform2 unitx2 unity2 + +stepWorld :: Elapsed -> Dt -> [GameEvent] -> [GameObject] -> [GameObject] +stepWorld elapsed dt evts gos = map (update elapsed dt evts gos) gos + +update :: Elapsed -> Dt -> [GameEvent] -> [GameObject] -> GameObject -> GameObject +update elapsed dt evts gos go = + let (go', s') = runStep (gostep go) elapsed dt gos evts go + in go' {gostep = s'} + -- Ball steppers stepBall vel = collideBall vel .> moveBall -- cgit v1.2.3