diff --git a/game.scm b/game.scm index 4207ce8..3f26f6b 100644 --- a/game.scm +++ b/game.scm @@ -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))))