summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game.scm28
1 files changed, 17 insertions, 11 deletions
diff --git a/game.scm b/game.scm
index 3eb10c5..c0353a2 100644
--- a/game.scm
+++ b/game.scm
@@ -593,10 +593,12 @@
(do ((x 0 (+ x 1)))
((= x level-width))
(case (s32-ref tiles (level-offset x y))
- ((0)
- #t)
+ ((0) #t)
((1)
- (spawn-enemy-a (* x tile-width) (* (- row y) tile-height))))))
+ (spawn-enemy-a (+ (* x tile-width)
+ (/ tile-width 2.0))
+ (+ (* (- row y 3) tile-height)
+ (/ tile-height 2.0)))))))
(set! *last-row-scanned* row))))))
;; Enemies
@@ -607,6 +609,7 @@
(health enemy-health set-enemy-health!)
(position enemy-position set-enemy-position!)
(size enemy-size set-enemy-size!)
+ (stationary? enemy-stationary? set-enemy-stationary!)
(velocity enemy-velocity set-enemy-velocity!)
(script enemy-script set-enemy-script!))
(define (enemy-x enemy)
@@ -623,18 +626,18 @@
(vec2-y (enemy-velocity enemy)))
(define (enemy-damage! enemy damage)
(match enemy
- (#('enemy type health position size velocity script)
+ (#('enemy type health _ _ _ _ _)
(set-enemy-health! enemy (- health damage)))))
(define (enemy-dead? enemy)
(<= (enemy-health enemy) 0))
(define (enemy-out-of-bounds? enemy)
(match enemy
- (#('enemy type health position size velocity script)
+ (#('enemy _ _ position size _ _ _)
(out-of-bounds? (vec2-x position) (vec2-y position)
(vec2-x size) (vec2-y size)))))
(define (enemy-within-rect? enemy x y w h)
(match enemy
- (#('enemy type health position size velocity script)
+ (#('enemy _ _ position size _ _ _)
(let* ((w* (vec2-x size))
(h* (vec2-y size))
(x* (- (vec2-x position) (/ w* 2.0)))
@@ -650,12 +653,15 @@
(script-cancel! script))))
(define (enemy-update! enemy)
(match enemy
- (#('enemy type health position size velocity script)
- (set-vec2-x! position (+ (vec2-x position) (vec2-x velocity)))
- (set-vec2-y! position (+ (vec2-y position) (vec2-y velocity))))))
+ (#('enemy _ _ position size stationary? velocity _)
+ (if stationary?
+ (set-vec2-y! position (+ (vec2-y position) *scroll-speed*))
+ (begin
+ (set-vec2-x! position (+ (vec2-x position) (vec2-x velocity)))
+ (set-vec2-y! position (+ (vec2-y position) (vec2-y velocity))))))))
(define (enemy-draw enemy)
(match enemy
- (#('enemy type health position size velocity script)
+ (#('enemy type _ position size _ _ _)
(let* ((t 0.0)
(x (vec2-x position))
(y (vec2-y position))
@@ -751,7 +757,7 @@
(wait 2)
(loop (+ theta 0.2)))))
(let ((enemy (make-enemy 'foo 20 (vec2 x y) (vec2 16.0 16.0)
- (vec2 0.0 1.0) script)))
+ #t (vec2 0.0 0.0) script)))
(enemy-pool-add! enemies enemy)))
;; Player state: