aboutsummaryrefslogtreecommitdiffstats
path: root/pong/pong.tdy
diff options
context:
space:
mode:
Diffstat (limited to 'pong/pong.tdy')
-rw-r--r--pong/pong.tdy11
1 files changed, 9 insertions, 2 deletions
diff --git a/pong/pong.tdy b/pong/pong.tdy
index e1eb210..9778dfc 100644
--- a/pong/pong.tdy
+++ b/pong/pong.tdy
@@ -46,8 +46,14 @@ or := fn a: bool, b: bool -> bool {
}
rect_overlap := fn ax: float, ay: float, aw: float, ah: float, bx: float, by: float, bw: float, bh: float -> bool {
- dx := abs(ax - bx) + (-aw - bw) / 2.
- dy := abs(ay - by) + (-ah - bh) / 2.
+ acx := ax + aw / 2.
+ acy := ay + ah / 2.
+
+ bcx := bx + bw / 2.
+ bcy := by + bh / 2.
+
+ dx := abs(acx - bcx) + (-aw - bw) / 2.
+ dy := abs(acy - bcy) + (-ah - bh) / 2.
ret and(dx < 0., dy < 0.)
}
@@ -85,6 +91,7 @@ update := fn state: State {
draw := fn state: State {
clear()
+
draw_rectangle(state.p1.paddle.x, state.p1.paddle.y, 0.2, 1.)
draw_rectangle(state.p2.paddle.x, state.p2.paddle.y, 0.2, 1.)