Changing the way game state is handled

This commit is contained in:
Amy Grinn 2024-12-20 09:09:12 -05:00
parent 3f463a9a61
commit b248ea72ad
No known key found for this signature in database
GPG key ID: 6B558BED1DCF3192

View file

@ -106,15 +106,21 @@
(define audio:bg-music (load-music "cirkoban"))
;; Game state
(define *state* (list #f))
(define *state* '())
(define (push-game-state! state)
(set! *state* (cons state *state*)))
(define (pop-game-state!)
(set! *state* (cdr *state*)))
(define (current-game-state) (car *state*))
(when (pair? *state*)
(set! *state* (cdr *state*))))
(define (replace-game-state! state)
(if (pair? *state*)
(set! *state* (cons state (cdr *state*)))
(set! *state* (list state))))
(define (current-game-state)
(when (pair? *state*)
(car *state*)))
(define *actormap* (make-whactormap))
@ -214,7 +220,7 @@
(memq idx *gems*))
(define (set-level! idx)
(push-game-state! 'play)
(replace-game-state! 'play)
(set! *actormap* (make-whactormap))
(clear-snapshots!)
(with-goblins
@ -222,7 +228,7 @@
(update-objects!)))
(define (load-credits!)
(push-game-state! 'win)
(replace-game-state! 'win)
(set! *actormap* (make-whactormap))
(set-vec2-y! *credits-scroll* 0.0)
(clear-snapshots!)
@ -239,7 +245,7 @@
(begin
(run-script
(lambda ()
(push-game-state! 'interstitial)
(replace-game-state! 'interstitial)
(yield
(lambda (k)
(show-effect! (make-fade-out+in-effect 1.0 k))))
@ -249,7 +255,7 @@
(begin
(run-script
(lambda ()
(push-game-state! 'interstitial)
(replace-game-state! 'interstitial)
(yield
(lambda (k)
(show-effect! (make-fade-out+in-effect 2.0 k))))
@ -403,7 +409,7 @@
(define (reset-game!)
(run-script
(lambda ()
(push-game-state! 'interstitial)
(set! *state* '(interstitial))
(yield
(lambda (k)
(show-effect! (make-fade-out+in-effect 2.0 k))))