diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-31 10:16:53 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-31 10:28:20 +0100 |
| commit | 4aa801b6b17e1c34c05d94850b9450c05f6c60d1 (patch) | |
| tree | 6a6d1dd590141b9ff6808edad13935db1b9a2b68 /pong | |
| parent | 837492e247eb9f50ba7837ff3565157a5542e32c (diff) | |
| download | sylt-4aa801b6b17e1c34c05d94850b9450c05f6c60d1.tar.gz | |
roof and floor
Diffstat (limited to 'pong')
| -rw-r--r-- | pong/pong.tdy | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pong/pong.tdy b/pong/pong.tdy index 5d9b277..fc54e36 100644 --- a/pong/pong.tdy +++ b/pong/pong.tdy @@ -100,6 +100,14 @@ update := fn state: State { state.ball.x = state.ball.x + delta * state.ball.vx state.ball.y = state.ball.y + delta * state.ball.vy + if state.ball.y < 0. { + state.ball.vy = abs(state.ball.vy) + } + + if state.ball.y > 20. - 0.2 { + state.ball.vy = -abs(state.ball.vy) + } + ball_and_paddle_check(state.p1.paddle, state.ball) ball_and_paddle_check(state.p2.paddle, state.ball) @@ -121,8 +129,8 @@ init := fn { state.ball = Ball() state.ball.x = 10.0 state.ball.y = 10.0 - state.ball.vx = 3.0 - state.ball.vy = 0.0 + state.ball.vx = 1.0 + state.ball.vy = 2.0 state.p1 = Player() state.p1.paddle = Paddle() |
