summaryrefslogtreecommitdiff
path: root/bonnie-bee/bullet.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2021-10-20 18:42:10 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2021-10-20 18:42:10 -0400
commitae60497f7722e01ccceebe799b5820717e048eb3 (patch)
tree7977b53565d5f1e259d90903213f1add3fefabce /bonnie-bee/bullet.scm
parentde833c9d524d2e47b3812612995290795d2e7b84 (diff)
Haven't committed in days, oops!
Diffstat (limited to 'bonnie-bee/bullet.scm')
-rw-r--r--bonnie-bee/bullet.scm46
1 files changed, 45 insertions, 1 deletions
diff --git a/bonnie-bee/bullet.scm b/bonnie-bee/bullet.scm
index 0fb351b..2cd722b 100644
--- a/bonnie-bee/bullet.scm
+++ b/bonnie-bee/bullet.scm
@@ -14,10 +14,18 @@
#:use-module (starling node)
#:use-module (starling node-2d)
#:export (<bullet-type>
- name
+ player-bullet?
+ player-primary-bullet?
+ player-bomb-bullet?
+ enemy-bullet?
player-primary-bullet
+ player-bomb-bullet
+ large-enemy-bullet
+ medium-enemy-bullet
+ small-enemy-bullet
pollen-pickup
<bullets>
+ clear-bullets
<bullet>
type
kill-bullet
@@ -36,6 +44,22 @@
(make <bullet-type> #:name 'player-primary #:atlas-index 4
#:hitbox (make-rect -7.0 -7.0 14.0 14.0)))
+(define player-bomb-bullet
+ (make <bullet-type> #:name 'player-bomb #:atlas-index 5
+ #:hitbox (make-rect -4.0 -4.0 8.0 8.0)))
+
+(define large-enemy-bullet
+ (make <bullet-type> #:name 'large-enemy #:atlas-index 0
+ #:hitbox (make-rect -4.0 -4.0 8.0 8.0)))
+
+(define medium-enemy-bullet
+ (make <bullet-type> #:name 'medium-enemy #:atlas-index 1
+ #:hitbox (make-rect -2.0 -2.0 4.0 4.0)))
+
+(define small-enemy-bullet
+ (make <bullet-type> #:name 'small-enemy #:atlas-index 2
+ #:hitbox (make-rect -0.5 -0.5 1.0 1.0)))
+
;; Yeah... pollen is a bullet. Didn't you know that??
(define pollen-pickup
(make <bullet-type> #:name 'pollen #:atlas-index 6
@@ -80,6 +104,9 @@
(set! (hitboxes bullets) (make-vector* %max-bullets make-null-rect))
(set! (regions bullets) (make-vector* %max-bullets make-null-rect)))
+(define-method (clear-bullets (bullets <bullets>))
+ (set! (size bullets) 0))
+
(define-class <bullet> ()
(parent #:getter parent #:init-keyword #:parent)
(type #:accessor type)
@@ -189,3 +216,20 @@
(set-rect-y! h (+ (rect-y h) (vec2-y v)))
(quadtree-insert! q h d)
(loop (+ i 1)))))))))
+
+(define (player-bullet? bullet)
+ (let ((t (type bullet)))
+ (or (eq? t player-primary-bullet)
+ (eq? t player-bomb-bullet))))
+
+(define (player-primary-bullet? bullet)
+ (eq? (type bullet) player-primary-bullet))
+
+(define (player-bomb-bullet? bullet)
+ (eq? (type bullet) player-bomb-bullet))
+
+(define (enemy-bullet? bullet)
+ (let ((t (type bullet)))
+ (or (eq? t small-enemy-bullet)
+ (eq? t medium-enemy-bullet)
+ (eq? t large-enemy-bullet))))