Changing the way game state is handled
This commit is contained in:
parent
3f463a9a61
commit
b248ea72ad
1 changed files with 15 additions and 9 deletions
24
game.scm
24
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))))
|
||||
|
|
Loading…
Add table
Reference in a new issue