aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdvard Thörnros <edvard.thornros@gmail.com>2021-01-31 10:16:53 +0100
committerEdvard Thörnros <edvard.thornros@gmail.com>2021-01-31 10:28:20 +0100
commit4aa801b6b17e1c34c05d94850b9450c05f6c60d1 (patch)
tree6a6d1dd590141b9ff6808edad13935db1b9a2b68
parent837492e247eb9f50ba7837ff3565157a5542e32c (diff)
downloadsylt-4aa801b6b17e1c34c05d94850b9450c05f6c60d1.tar.gz
roof and floor
-rw-r--r--pong/pong.tdy12
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()