summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-10-28 15:48:08 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-10-28 15:48:08 -0400
commit5100195b44eeab31cf0e8cf77cbe6e99f3fb4620 (patch)
treebbfcfccecb54b49b910bf8054de144139d690a6d
parent9273ffb77ad3ddb2630c61a38618e2639ed34097 (diff)
Change turret firing pattern.
-rw-r--r--game.scm30
1 files changed, 17 insertions, 13 deletions
diff --git a/game.scm b/game.scm
index f9ac6e9..441298c 100644
--- a/game.scm
+++ b/game.scm
@@ -954,19 +954,23 @@
(define (spawn-turret x y)
(define (script enemy)
(let ((speed 2.0))
- (wait 60)
- (let loop ((theta 0.0))
- (let ((dx (* (cos theta) speed))
- (dy (* (sin theta) speed))
- (v (direction-to-player (enemy-position enemy))))
- (bullet-pool-add! enemy-bullets 0
- (enemy-x enemy)
- (enemy-y enemy)
- 2.0 2.0
- (* (vec2-x v) speed)
- (* (vec2-y v) speed)))
- (wait 30)
- (loop (+ theta 0.2)))))
+ (define (current-dir)
+ (direction-to-player (enemy-position enemy)))
+ (define (shoot dir)
+ (bullet-pool-add! enemy-bullets 0
+ (enemy-x enemy)
+ (enemy-y enemy)
+ 2.0 2.0
+ (* (vec2-x dir) speed)
+ (* (vec2-y dir) speed)))
+ (forever
+ (wait 60)
+ (let ((dir (current-dir)))
+ (shoot dir)
+ (wait 10)
+ (shoot dir)
+ (wait 10)
+ (shoot dir)))))
(spawn-turret* x y script))
(define (spawn-popcorn x y)