From 60abc8ae6529bdc67454f15689be901128730f98 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 29 Oct 2023 23:24:40 -0400 Subject: Final edits. --- game.scm | 159 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 93 insertions(+), 66 deletions(-) diff --git a/game.scm b/game.scm index cb36f3e..7e7ddf1 100644 --- a/game.scm +++ b/game.scm @@ -1250,7 +1250,7 @@ (particle-pool-add! particles 'muzzle-flash life x y rdx dy))) (define (shoot type x y dx dy) (let ((s (if (= type 4) 4.0 2.0))) - (bullet-pool-add! enemy-bullets 0 x y s s dx dy))) + (bullet-pool-add! enemy-bullets type x y s s dx dy))) (define (xoff dx) (+ (enemy-x boss) dx)) (define (yoff dy) @@ -1267,13 +1267,15 @@ (define alt-right-x 58.0) (define alt-y 28.0) (define (shoot-main-left type dx dy) - (shoot+flash main-left-x type main-y dx dy)) + (shoot+flash type main-left-x main-y dx dy)) (define (shoot-main-right type dx dy) - (shoot+flash main-right-x type main-y dx dy)) + (shoot+flash type main-right-x main-y dx dy)) (define (shoot-alt-left type dx dy) - (shoot+flash alt-left-x type alt-y dx dy)) + (shoot+flash type alt-left-x alt-y dx dy)) (define (shoot-alt-right type dx dy) - (shoot+flash alt-right-x type alt-y dx dy)) + (shoot+flash type alt-right-x alt-y dx dy)) + (define (shoot-beak type dx dy) + (shoot+flash type 0.0 24.0 dx dy)) (define (player-dir dx dy) (let ((p (enemy-position boss))) (direction-to-player @@ -1288,60 +1290,20 @@ (loop (- d 1)) (alternate)))))) (define (nop) #f) - ;; alt guns make Xs across the screen - ;; main guns shoot at player - ;; beak shoots spiral - (define (phase-2) - (define (pred) (> (enemy-health boss) 500)) - (wait 180) - (run-script - (lambda () - (let loop () - (let ((dx 2.0) - (dy 4.0)) - (do ((i 0 (+ i 1))) - ((= i 30)) - (shoot-alt-left 0 dx dy) - (shoot-alt-right 0 (- dx) dy) - (wait 4)) - (wait-if 60 pred loop nop))))) - (run-script - (lambda () - (wait 120) - (let loop () - (let ((v (player-dir main-left-x main-y))) - (vec2-mul-scalar! v 3.5) - (do ((i 0 (+ i 1))) - ((= i 5)) - (shoot-main-left 0 (vec2-x v) (vec2-y v)) - (wait 4))) - (wait-if 120 pred loop nop)))) - (run-script - (lambda () - (wait 60) - (let loop () - (let ((v (player-dir main-right-x main-y))) - (vec2-mul-scalar! v 3.5) - (do ((i 0 (+ i 1))) - ((= i 5)) - (shoot-main-right 0 (vec2-x v) (vec2-y v)) - (wait 4))) - (wait-if 120 pred loop nop)))) - (let ((x (enemy-x boss)) - (y (+ (enemy-y boss) 48.0)) - (speed 0.75)) - (let loop ((offset 0.0)) - (do-circle - (lambda (theta) - (let ((theta* (+ theta offset))) - (shoot 0 x y (* (cos theta*) speed) (* (sin theta*) speed)))) - 3) - (wait-if 10 pred (lambda () (loop (+ offset 0.3))) phase-3)))) - ;; intense alt fire aimed at player - ;; half-circle arcs of bullets at player (define (phase-3) (define (pred) #t) (wait 180) + (run-script + (lambda () + (let ((speed 4.0)) + (let loop ((theta 0.0)) + (let ((theta* (+ (fmod theta (/ pi 3.0)) (/ pi 3.0))) + (theta** (+ (- (/ pi 3.0) (fmod theta (/ pi 3.0))) (/ pi 3.0))) + (speed 4.0)) + (shoot-alt-left 4 (* (cos theta*) speed) (* (sin theta*) speed)) + (shoot-alt-right 4 (* (cos theta**) speed) (* (sin theta**) speed)) + (wait 30) + (loop (+ theta 0.35))))))) (run-script (lambda () (wait 120) @@ -1353,7 +1315,7 @@ (shoot-alt-left 0 (vec2-x v) (vec2-y v)) (wait 4) (inner (+ i 1)))) - (wait-if 10 pred outer nop))))) + (wait-if 30 pred outer nop))))) (run-script (lambda () (wait 60) @@ -1365,19 +1327,67 @@ (shoot-alt-right 0 (vec2-x v) (vec2-y v)) (wait 4) (inner (+ i 1)))) - (wait-if 10 pred outer nop))))) + (wait-if 30 pred outer nop))))) (let ((speed 1.0) (k 10)) (let outer () (let inner ((i 0)) (when (<= i k) (let ((theta (* (inexact (/ i k)) pi))) - (shoot-main-left 4 (* (cos theta) speed) (* (sin theta) speed)) - (shoot-main-right 4 (* (cos theta) speed) (* (sin theta) speed)) + (shoot-beak 4 (* (cos theta) speed) (* (sin theta) speed)) (inner (+ i 1))))) (wait-if 60 pred outer nop)))) - ;; alt guns fired aimed shots at player - ;; main guns shoot spirals + (define (phase-2) + (define (pred) (> (enemy-health boss) 500)) + (wait 180) + (run-script + (lambda () + (let loop () + (let ((dx 2.0) + (dy 4.0)) + (do ((i 0 (+ i 1))) + ((= i 30)) + (shoot-alt-left 0 dx dy) + (shoot-alt-right 0 (- dx) dy) + (wait 4)) + (wait-if 60 pred loop nop))))) + (run-script + (lambda () + (wait 120) + (let loop () + (let ((v (player-dir main-left-x main-y))) + (vec2-mul-scalar! v 3.5) + (do ((i 0 (+ i 1))) + ((= i 5)) + (shoot-main-left 0 (vec2-x v) (vec2-y v)) + (wait 4))) + (wait-if 120 pred loop nop)))) + (run-script + (lambda () + (wait 60) + (let loop () + (let ((v (player-dir main-right-x main-y))) + (vec2-mul-scalar! v 3.5) + (do ((i 0 (+ i 1))) + ((= i 5)) + (shoot-main-right 0 (vec2-x v) (vec2-y v)) + (wait 4))) + (wait-if 120 pred loop nop)))) + (run-script + (lambda () + (let loop ((theta 0.0)) + (let ((theta* (+ (fmod theta (/ pi 3.0)) (/ pi 3.0))) + (speed 4.0)) + (shoot-beak 4 (* (cos theta*) speed) (* (sin theta*) speed)) + (wait-if 30 pred (lambda () (loop (+ theta 0.35))) nop))))) + (let ((speed 1.2)) + (let loop ((offset 0.0)) + (do-circle + (lambda (theta) + (let ((theta* (+ theta offset))) + (shoot-beak 0 (* (cos theta*) speed) (* (sin theta*) speed)))) + 3) + (wait-if 5 pred (lambda () (loop (+ offset 0.1))) phase-3)))) (define (phase-1) (define (pred) (> (enemy-health boss) 1000)) (run-script @@ -1402,6 +1412,13 @@ (shoot-alt-right 0 (vec2-x v) (vec2-y v)) (wait 4))) (wait-if 120 pred loop nop)))) + (run-script + (lambda () + (let loop ((theta 0.0)) + (let ((theta* (+ (fmod theta (/ pi 3.0)) (/ pi 3.0))) + (speed 4.0)) + (shoot-beak 4 (* (cos theta*) speed) (* (sin theta*) speed)) + (wait-if 30 pred (lambda () (loop (+ theta 0.35))) nop))))) (let ((speed 0.75)) (let loop ((theta 0.0)) (let ((dx (* (cos theta) speed)) @@ -1410,9 +1427,20 @@ (shoot-main-right 0 (- dx) dy) (wait-if 5 pred (lambda () (loop (+ theta 0.4))) phase-2))))) (wait 180) + (run-script + (lambda () + (forever + (tween (lambda (dx) + (set-enemy-dx! boss dx)) + 60 -0.5 0.5 + smoothstep lerp) + (tween (lambda (dx) + (set-enemy-dx! boss dx)) + 60 0.5 -0.5 + smoothstep lerp)))) (phase-1)) (spawn-enemy - (make-enemy 'boss 1500 (vec2 x (- y 32.0)) (vec2 144.0 50.0) + (make-enemy 'boss 1500 (vec2 x (- y 32.0)) (vec2 144.0 64.0) (vec2 0.0 0.0) script 500000 #(0.0 144.0 288.0 432.0) image:boss (vec2 144.0 96.0)))) @@ -1844,11 +1872,10 @@ (set! *game-state* 'play) (scheduler-reset! *scheduler*) (set! *scroll* 0.0) - ;; (set! *scroll* (* 140.0 tile-height)) + ;; (set! *scroll* (* 460.0 tile-height)) (set! *last-scroll* 0.0) (set! *last-row-scanned* (level-height level)) - ;; (set! *last-row-scanned* (- (level-height level) - ;; 140)) + ;; (set! *last-row-scanned* (- (level-height level) 460)) (bullet-pool-reset! player-bullets) (bullet-pool-reset! enemy-bullets) (enemy-pool-reset! enemies) -- cgit v1.2.3