summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-10-22 20:36:32 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-10-22 20:36:32 -0400
commit62b9299417dede88889fd9e86d4619211d2bcc7a (patch)
treed7a3c30063879d3e5819f0a32143e5b1d90e99fd
parent07f7219be17097f08dac90a4d0f38f7c6e843722 (diff)
Player can be hit by enemy bullets.
-rw-r--r--game.scm13
1 files changed, 12 insertions, 1 deletions
diff --git a/game.scm b/game.scm
index 36f99d6..6f51d5a 100644
--- a/game.scm
+++ b/game.scm
@@ -696,7 +696,18 @@
(let ((x* (- x (/ w 2.0)))
(y* (- y(/ h 2.0))))
(or (out-of-bounds? x* y* w h)
- (rect-collides-with-level? level x* y* w h))))
+ (rect-collides-with-level? level x* y* w h)
+ (if (rect-within? x y w h
+ (- (vec2-x player-position)
+ (/ player-hitbox-width 2.0))
+ (- (vec2-y player-position)
+ (/ player-hitbox-height 2.0))
+ player-hitbox-width
+ player-hitbox-height)
+ (begin
+ (player-die!)
+ #t)
+ #f))))
(define (enemy-collide x y w h hp)
hp)