summaryrefslogtreecommitdiff
path: root/depre/main.scm
diff options
context:
space:
mode:
Diffstat (limited to 'depre/main.scm')
-rw-r--r--depre/main.scm35
1 files changed, 30 insertions, 5 deletions
diff --git a/depre/main.scm b/depre/main.scm
index 81bdb03..11b18fc 100644
--- a/depre/main.scm
+++ b/depre/main.scm
@@ -25,6 +25,18 @@
((car fs))
(loop (cdr fs))))))
+;; Transition by chance, according to the state
+;; Example:
+;; - You are too tired for that, so you do this instead
+;; - Or you actually do it
+(define (f-or-tired f tired)
+ #f
+ )
+
+(define (f-or-depressed f depressed)
+ #f
+ )
+
;; Simple I/O
(define (answer message)
(lambda ()
@@ -71,16 +83,29 @@
(loop (read)))))))
;; States:
-(define start
+
+;; Some macro magic for indirection that enables recursion.
+;; I don't really know how it works (yet!)
+(define %states (make-hash-table))
+(define-macro (register-state name f)
+ `(hash-set! %states ,name ,f))
+(define-macro (to-state name)
+ `(lambda () ((hash-ref %states ,name))))
+
+(register-state
+ 'begining
+ (state "This is the game beginning, as a test"
+ (list (cons "Return to start" (to-state 'start)))))
+
+(register-state
+ 'start
(state "Hi, game starts"
(list (cons "Start game"
(combine
(answer "Let's start, then.")
- (state "heading"
- (list (cons "hola" (lambda () (display "HOLA")))
- (cons "adios" (lambda () (display "adios")))))))
+ (to-state 'begining)))
(cons "Quit game"
(answer "Good bye!")))
#:hide-status))
-(start)
+((to-state 'start))