diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-03-10 20:19:22 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-03-10 20:19:22 -0400 |
commit | 718cc7c73318b09d595ddc2072b74062430ae896 (patch) | |
tree | 60a0e505bdb4004f0d66ca4aa7ef8027e275d5b0 | |
parent | f0ae9c3b2a6ef4cef53a2040685053a66c7e8b71 (diff) |
Don't start the REPL server upon importing (2d repl).
* 2d/repl.scm (start-2d-repl): New procedure.
* examples/common.scm: Start the REPL server.
* sandbox: Start the REPL server.
-rw-r--r-- | 2d/repl.scm | 18 | ||||
-rw-r--r-- | examples/common.scm | 2 | ||||
-rwxr-xr-x | sandbox | 4 |
3 files changed, 16 insertions, 8 deletions
diff --git a/2d/repl.scm b/2d/repl.scm index c2dec6c..02237b6 100644 --- a/2d/repl.scm +++ b/2d/repl.scm @@ -23,12 +23,16 @@ (define-module (2d repl) #:use-module (system repl coop-server) + #:use-module (system repl server) #:use-module (2d agenda) - #:use-module (2d game)) + #:use-module (2d game) + #:export (start-2d-repl)) -(define server (spawn-coop-repl-server)) - -(define (poll-server) - (poll-coop-repl-server server)) - -(schedule-interval game-agenda poll-server 2) +(define* (start-2d-repl #:optional (port (make-tcp-server-socket #:port 37146))) + "Start a cooperative REPL server that listens on the given PORT. By +default, this port is 37146. Additionally, a process is scheduled to +poll the REPL server upon every tick of the game loop." + (let ((server (spawn-coop-repl-server port))) + (schedule-each game-agenda + (lambda () + (poll-coop-repl-server server))))) diff --git a/examples/common.scm b/examples/common.scm index 6631514..8b1263d 100644 --- a/examples/common.scm +++ b/examples/common.scm @@ -33,3 +33,5 @@ (lambda () (format #t "FPS: ~d\n" (signal-ref fps))) 60) + +(start-2d-repl) @@ -38,10 +38,12 @@ (2d window) (2d repl)) -(display "Welcome to the guile-2d sandbox. Happy hacking!\n") +(start-2d-repl) (add-hook! window-close-hook quit-game) +(display "Welcome to the guile-2d sandbox. Happy hacking!\n") + (with-window (make-window #:title "Guile-2D Sandbox") (run-game-loop)) |