Add end-game credits sequence.
This commit is contained in:
parent
91ba2fab66
commit
4ec1666a1d
6 changed files with 110 additions and 6 deletions
77
game.scm
77
game.scm
|
@ -33,6 +33,7 @@
|
|||
(game levels level-2)
|
||||
(game levels level-3)
|
||||
(game levels level-4)
|
||||
(game levels credits)
|
||||
(game scripts)
|
||||
(game tileset)
|
||||
(goblins core)
|
||||
|
@ -168,6 +169,15 @@
|
|||
(set! *level* ((vector-ref levels idx) (collected-gem? idx)))
|
||||
(update-objects!)))
|
||||
|
||||
(define (load-credits!)
|
||||
(set! *state* 'win)
|
||||
(set! *actormap* (make-whactormap))
|
||||
(set-vec2-y! *credits-scroll* 0.0)
|
||||
(clear-snapshots!)
|
||||
(with-goblins
|
||||
(set! *level* (load-credits #t))
|
||||
(update-objects!)))
|
||||
|
||||
(define (next-level!)
|
||||
(let ((idx (+ *level-idx* 1)))
|
||||
(pk 'next-level idx)
|
||||
|
@ -177,10 +187,19 @@
|
|||
(save-game!)
|
||||
(run-script
|
||||
(lambda ()
|
||||
(set! *state* 'interstitial)
|
||||
(show-effect! (make-fade-out+in-effect 1.0))
|
||||
(wait 30) ; ~half the effect time
|
||||
(wait 30) ; ~half the effect time
|
||||
(load-level! idx))))
|
||||
(set! *state* 'win))))
|
||||
(begin
|
||||
(run-script
|
||||
(lambda ()
|
||||
(set! *level-idx* 0)
|
||||
(save-game!)
|
||||
(set! *state* 'interstitial)
|
||||
(show-effect! (make-fade-out+in-effect 2.0))
|
||||
(wait 60)
|
||||
(load-credits!)))))))
|
||||
|
||||
;; Auto-save/load to local storage.
|
||||
(define (save-game!)
|
||||
|
@ -390,10 +409,58 @@
|
|||
(define (draw-interstitial)
|
||||
(draw-level))
|
||||
|
||||
(define *credits-scroll* (vec2 0.0 0.0))
|
||||
(define credits
|
||||
#("Congratulations!"
|
||||
#f
|
||||
#f
|
||||
"Cirkoban was made by the"
|
||||
"Spritely Institute"
|
||||
#f
|
||||
"https://spritely.institute"
|
||||
#f
|
||||
"Programming"
|
||||
#f
|
||||
"David Thompson"
|
||||
"Juliana Sims"
|
||||
#f
|
||||
"Art"
|
||||
#f
|
||||
"Christine Lemmer-Webber"
|
||||
#f
|
||||
"monogram font by datagoblin"
|
||||
#f
|
||||
#f
|
||||
#f
|
||||
#f
|
||||
#f
|
||||
#f
|
||||
#f
|
||||
#f
|
||||
"Thank you for playing!"))
|
||||
(define credits-line-spacing 16.0)
|
||||
(define max-credits-scroll
|
||||
(+ game-height (* (- (vector-length credits) 9) credits-line-spacing)))
|
||||
(define (draw-win)
|
||||
(set-fill-color! context "#000000")
|
||||
(set-text-align! context "left")
|
||||
(fill-text context "OMG YOU DID IT WOW CONGRATS" 32.0 120.0))
|
||||
(draw-level)
|
||||
(set-fill-color! context "#ffffff")
|
||||
(set-text-align! context "center")
|
||||
(set-font! context "bold 16px monogram")
|
||||
(set-vec2-y! *credits-scroll*
|
||||
(min (+ (vec2-y *credits-scroll*) 1.0)
|
||||
max-credits-scroll))
|
||||
(let* ((x (* game-width 0.7))
|
||||
(lines-on-screen 15)
|
||||
(scroll-y (vec2-y *credits-scroll*))
|
||||
;; TODO: Only render the lines on screen.
|
||||
(start 0)
|
||||
(end (vector-length credits)))
|
||||
(let lp ((i start) (y (- game-height scroll-y)))
|
||||
(when (< i end)
|
||||
(match (vector-ref credits i)
|
||||
(#f #f)
|
||||
(str (fill-text context str x y)))
|
||||
(lp (1+ i) (+ y credits-line-spacing))))))
|
||||
|
||||
(define (draw prev-time)
|
||||
(clear-rect context 0.0 0.0 *canvas-width* *canvas-height*)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue