diff options
Diffstat (limited to 'Demos/Pong/Pong.hs')
-rw-r--r-- | Demos/Pong/Pong.hs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Demos/Pong/Pong.hs b/Demos/Pong/Pong.hs index 943682f..2bd9df1 100644 --- a/Demos/Pong/Pong.hs +++ b/Demos/Pong/Pong.hs | |||
@@ -40,9 +40,7 @@ initialBallPos = vec2 0.5 0.5 | |||
40 | data GameEvent | 40 | data GameEvent |
41 | = MoveLeft | 41 | = MoveLeft |
42 | | MoveRight | 42 | | MoveRight |
43 | | StopLeft | 43 | deriving (Eq, Ord, Show) |
44 | | StopRight | ||
45 | deriving (Eq, Ord) | ||
46 | 44 | ||
47 | -- Game objects | 45 | -- Game objects |
48 | 46 | ||
@@ -163,11 +161,10 @@ movePad = step $ \elapsed _ _ _ pad -> | |||
163 | 161 | ||
164 | stepPlayer = sfold moveGO .> clamp | 162 | stepPlayer = sfold moveGO .> clamp |
165 | 163 | ||
166 | moveGO = | 164 | moveGO = mconcat |
167 | mconcat | 165 | [ swhen MoveLeft $ moveGO' (vec2 (-playerSpeed) 0) |
168 | [ switch StopLeft sid MoveLeft (moveGO' $ vec2 (-playerSpeed) 0), | 166 | , swhen MoveRight $ moveGO' (vec2 playerSpeed 0) |
169 | switch StopRight sid MoveRight (moveGO' $ vec2 playerSpeed 0) | 167 | ] |
170 | ] | ||
171 | 168 | ||
172 | moveGO' :: Vector2 -> Step s e GameObject GameObject | 169 | moveGO' :: Vector2 -> Step s e GameObject GameObject |
173 | moveGO' dir = step $ \_ dt _ _ go -> (translate (dir * dt) go, moveGO' dir) | 170 | moveGO' dir = step $ \_ dt _ _ go -> (translate (dir * dt) go, moveGO' dir) |