Setting initial game state

Use matching for game state procedures
This commit is contained in:
Amy Grinn 2024-12-31 13:14:17 -05:00
parent 514c7db401
commit 27b6a4d840
No known key found for this signature in database
GPG key ID: 6B558BED1DCF3192

View file

@ -106,7 +106,7 @@
(define audio:bg-music (load-music "cirkoban"))
;; Game state
(define *state* '())
(define *state* '(initial))
(define (push-game-state! state)
(set! *state* (cons state *state*)))
@ -114,14 +114,12 @@
(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))))
(match *state*
((_ . rest)
(set! *state* (cons state rest)))))
(define (current-game-state)
(when (pair? *state*)
(car *state*)))
(match *state*
((state . _) state)))
(define *actormap* (make-whactormap))
(define (call-with-goblins thunk)
@ -401,7 +399,7 @@
(define (reset-game!)
(run-script
(lambda ()
(set! *state* '(interstitial))
(replace-game-state! 'interstitial)
(yield
(lambda (k)
(show-effect! (make-fade-out+in-effect 2.0 k))))
@ -1051,7 +1049,8 @@
(with-goblins (update-objects!)))
;; REMOVE BEFORE RELEASE!!!!
;; ('confirm (next-level!))
('menu (show-menu!))))
('menu (show-menu!))
(_ #f)))
('menu
(match input
('up (menu-up!))
@ -1061,7 +1060,8 @@
(_ #f)))
;; Pressing any bound input resets the game.
;; If traveling to the credits via the menu, go back to '*level-last*'
('credits (cond
('credits
(cond
(*level-last*
(load-level! *level-last*)
(set! *level-last* #f))