diff options
| -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() |
