diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-01-31 10:23:40 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-01-31 10:23:40 +0100 |
| commit | 837492e247eb9f50ba7837ff3565157a5542e32c (patch) | |
| tree | 47c77d5595307448f37a7ea454e616d287190b47 /pong/pong.tdy | |
| parent | 2f32aa0f1848f937992254fd9a610264784aefbd (diff) | |
| download | sylt-837492e247eb9f50ba7837ff3565157a5542e32c.tar.gz | |
ball bouncy sideways
Diffstat (limited to 'pong/pong.tdy')
| -rw-r--r-- | pong/pong.tdy | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pong/pong.tdy b/pong/pong.tdy index cb861f9..5d9b277 100644 --- a/pong/pong.tdy +++ b/pong/pong.tdy @@ -66,11 +66,16 @@ rect_overlap := fn ax: float, ay: float, aw: float, ah: float, bx: float, by: fl ball_and_paddle_check := fn pad: Paddle, ball: Ball { if rect_overlap(ball.x, ball.y, 0.2, 0.2, pad.x, pad.y, 0.2, 1.) { + ballcy := ball.y + 0.1 + padcy := pad.y + 0.5 if ball.x < pad.x { ball.vx = -abs(ball.vx) + ball.vy = (ballcy - padcy) * 3. } else { ball.vx = abs(ball.vx) + ball.vy = (ballcy - padcy) * 3. } + log(ball.vx, ball.vy) } } @@ -116,7 +121,7 @@ init := fn { state.ball = Ball() state.ball.x = 10.0 state.ball.y = 10.0 - state.ball.vx = 1.0 + state.ball.vx = 3.0 state.ball.vy = 0.0 state.p1 = Player() |
