Support current-ground-dataspace for syndicate-gl.

This commit is contained in:
Tony Garnock-Jones 2016-07-16 16:15:19 -04:00
parent 4496258d0e
commit 4f570fcd18
4 changed files with 32 additions and 30 deletions

View File

@ -1029,10 +1029,8 @@
(define game-level 3) ;; used to specify meta-level to reach external I/O (define game-level 3) ;; used to specify meta-level to reach external I/O
(2d-dataspace #:width 600 #:height 400 ((2d-dataspace #:width 600 #:height 400)
(spawn-keyboard-integrator) (spawn-keyboard-integrator)
(spawn-scene-manager) (spawn-scene-manager)
(spawn-dataspace (spawn-score-keeper) (spawn-dataspace (spawn-score-keeper)
(spawn-level-spawner 0) (spawn-level-spawner 0)))
)
)

View File

@ -387,9 +387,10 @@
(super-new (style '(gl no-autoclear))))) (super-new (style '(gl no-autoclear)))))
(define (2d-dataspace #:width [width #f] (define ((2d-dataspace #:width [width #f]
#:height [height #f] #:height [height #f]
. boot-actions) #:exit? [exit? #t])
. boot-actions)
(collect-garbage 'incremental) (collect-garbage 'incremental)
(collect-garbage 'major) (collect-garbage 'major)
(define frame (new frame% (define frame (new frame%
@ -404,4 +405,5 @@
(error '2d-dataspace "OpenGL context failed to initialize")) (error '2d-dataspace "OpenGL context failed to initialize"))
(send c focus) (send c focus)
(send frame show #t) (send frame show #t)
(yield 'wait)) (yield 'wait)
(when exit? (exit 0)))

View File

@ -1,7 +1,6 @@
#lang racket #lang syndicate/actor
(require (only-in syndicate seal)) (require racket/set)
(require syndicate/actor)
(require 2htdp/image) (require 2htdp/image)
(require "../2d.rkt") (require "../2d.rkt")
@ -53,14 +52,15 @@
(define fps (/ counter (/ sim-time-ms 1000.0))) (define fps (/ counter (/ sim-time-ms 1000.0)))
(i (text (format "~a fps" fps) 22 "black"))))))) (i (text (format "~a fps" fps) 22 "black")))))))
(2d-dataspace (spawn-keyboard-integrator) (spawn-keyboard-integrator)
(spawn-background) (spawn-background)
;; (spawn-frame-counter) ;; (spawn-frame-counter)
(spawn-player-avatar) (spawn-player-avatar)
(actor (react (assert (simple-sprite 0 50 50 50 50 (circle 50 "solid" "orange")) (actor (react (assert (simple-sprite 0 50 50 50 50 (circle 50 "solid" "orange"))
#:meta-level 1) #:meta-level 1)
(assert (simple-sprite -1 60 60 50 50 (circle 50 "solid" "green")) (assert (simple-sprite -1 60 60 50 50 (circle 50 "solid" "green"))
#:meta-level 1))) #:meta-level 1)))
(actor (until (message (key-event #\q #t _) #:meta-level 1)) (actor (until (message (key-event #\q #t _) #:meta-level 1))
(assert! 'stop #:meta-level 1))) (assert! 'stop #:meta-level 1))
(exit 0)
(module+ main (current-ground-dataspace (2d-dataspace)))

View File

@ -13,14 +13,16 @@
@section{Creating Dataspaces} @section{Creating Dataspaces}
@defproc[(2d-dataspace [#:width width number? 640] @defproc[((2d-dataspace [#:width width number? 640]
[#:height height number? 480] [#:height height number? 480]
[boot-actions action?] ...) [#:exit? exit? boolean? #t])
[boot-actions action?] ...)
any/c]{ any/c]{
Create and run a @racket[frame%] with dimensions @racket[width] and Create and run a @racket[frame%] with dimensions @racket[width] and
@racket[height] controlled by a Syndicate dataspace. The dataspace is @racket[height] controlled by a Syndicate dataspace. The dataspace is
initialized with the given @racket[boot-actions]. Runs (blocking) while the initialized with the given @racket[boot-actions]. Runs (blocking)
@racket[frame%] is active. while the @racket[frame%] is active. If @racket[exit?] is true, calls
@racket[(exit 0)] once the dataspace exits.
} }
@defproc[(spawn-keyboard-integrator @defproc[(spawn-keyboard-integrator