summaryrefslogtreecommitdiff
path: root/2d/stage.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-12-01 21:47:30 -0500
committerDavid Thompson <dthompson2@worcester.edu>2013-12-01 21:47:30 -0500
commit936dcbf5179177d38514c3afb5dc185a808db80d (patch)
treeb5970b2e5124d5821d1780f5335e05d7a37c5f8b /2d/stage.scm
parente7907f648f3c576615c5ead2d9fc4fa156b6a97c (diff)
Delete obsolete modules.
* 2d/actions.scm: Delete it. * 2d/observer.scm: Delete it. * 2d/scene.scm: Delete it. * 2d/stage.scm: Delete it.
Diffstat (limited to '2d/stage.scm')
-rw-r--r--2d/stage.scm132
1 files changed, 0 insertions, 132 deletions
diff --git a/2d/stage.scm b/2d/stage.scm
deleted file mode 100644
index 5f5d8ca..0000000
--- a/2d/stage.scm
+++ /dev/null
@@ -1,132 +0,0 @@
-;;; guile-2d
-;;; Copyright (C) 2013 David Thompson <dthompson2@worcester.edu>
-;;;
-;;; Guile-2d is free software: you can redistribute it and/or modify it
-;;; under the terms of the GNU Lesser General Public License as
-;;; published by the Free Software Foundation, either version 3 of the
-;;; License, or (at your option) any later version.
-;;;
-;;; Guile-2d is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;;; Lesser General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU Lesser General Public
-;;; License along with this program. If not, see
-;;; <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; Stages represent the game state at the present time.
-;;
-;;; Code:
-
-(define-module (2d stage)
- #:use-module (srfi srfi-9)
- #:use-module (2d agenda)
- #:use-module (2d scene)
- #:export (make-stage
- stage?
- stage-agenda
- stage-state
- stage-scene
- set-stage-scene!
- enter-stage
- exit-stage
- draw-stage
- update-stage
- stage-trigger
- make-stage-variable
- define-stage-variable
- stage-on
- stage-off
- current-stage
- push-scene
- pop-scene
- replace-scene))
-
-(define-record-type <stage>
- (%make-stage agenda scene state)
- stage?
- (agenda stage-agenda)
- (scene stage-scene set-stage-scene!)
- (state stage-state))
-
-(define (make-stage scene)
- "Create a new stage object for SCENE."
- (%make-stage (make-agenda) scene (init-scene scene)))
-
-;;;
-;;; Scene callbacks
-;;;
-
-(define (enter-stage stage)
- "Call the scene enter callback for STAGE."
- (with-agenda (stage-agenda stage)
- (enter-scene (stage-scene stage)
- (stage-state stage))))
-
-(define (exit-stage stage)
- "Call the scene exit callback for STAGE."
- (with-agenda (stage-agenda stage)
- (exit-scene (stage-scene stage)
- (stage-state stage))))
-
-(define (update-stage stage)
- "Call the scene update callback for STAGE."
- (with-agenda (stage-agenda stage)
- (update-agenda)
- (update-scene (stage-scene stage)
- (stage-state stage))))
-
-(define (draw-stage stage)
- "Call the scene draw callback for STAGE."
- (with-agenda (stage-agenda stage)
- (draw-scene (stage-scene stage)
- (stage-state stage))))
-
-(define (stage-trigger stage event . args)
- (with-agenda (stage-agenda stage)
- (apply scene-trigger
- (stage-scene stage)
- (stage-state stage)
- event
- args)))
-
-;;;
-;;; Stage management
-;;;
-
-(define stack '())
-
-(define (current-stage)
- "Return the top of the stage stack or #f if the stack is empty."
- (if (null? stack) #f (car stack)))
-
-(define (push-scene scene)
- "Make STAGE active and push it to the top of the stack."
- (let ((prev-stage (current-stage))
- (stage (make-stage scene)))
- (when prev-stage
- (exit-stage prev-stage))
- (set! stack (cons stage stack))
- (enter-stage stage)))
-
-(define (pop-scene)
- "Replace the current stage with the next one on the stack, if
-present."
- (let ((prev-stage (current-stage)))
- (when prev-stage
- (exit-stage prev-stage))
- (set! stack (cdr stack))
- (when (current-stage)
- (enter-stage (current-stage)))))
-
-(define (replace-scene scene)
- "Replace the current stage with STAGE."
- (let ((prev-stage (current-stage))
- (stage (make-stage scene)))
- (when prev-stage
- (exit-stage prev-stage))
- (set! stack (cons stage (cdr stack)))
- (enter-stage stage)))