diff options
-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)) |