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
(2d-dataspace #:width 600 #:height 400
(spawn-keyboard-integrator)
(spawn-scene-manager)
(spawn-dataspace (spawn-score-keeper)
(spawn-level-spawner 0)
)
)
((2d-dataspace #:width 600 #:height 400)
(spawn-keyboard-integrator)
(spawn-scene-manager)
(spawn-dataspace (spawn-score-keeper)
(spawn-level-spawner 0)))

View File

@ -387,9 +387,10 @@
(super-new (style '(gl no-autoclear)))))
(define (2d-dataspace #:width [width #f]
#:height [height #f]
. boot-actions)
(define ((2d-dataspace #:width [width #f]
#:height [height #f]
#:exit? [exit? #t])
. boot-actions)
(collect-garbage 'incremental)
(collect-garbage 'major)
(define frame (new frame%
@ -404,4 +405,5 @@
(error '2d-dataspace "OpenGL context failed to initialize"))
(send c focus)
(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 syndicate/actor)
(require racket/set)
(require 2htdp/image)
(require "../2d.rkt")
@ -53,14 +52,15 @@
(define fps (/ counter (/ sim-time-ms 1000.0)))
(i (text (format "~a fps" fps) 22 "black")))))))
(2d-dataspace (spawn-keyboard-integrator)
(spawn-background)
;; (spawn-frame-counter)
(spawn-player-avatar)
(actor (react (assert (simple-sprite 0 50 50 50 50 (circle 50 "solid" "orange"))
#:meta-level 1)
(assert (simple-sprite -1 60 60 50 50 (circle 50 "solid" "green"))
#:meta-level 1)))
(actor (until (message (key-event #\q #t _) #:meta-level 1))
(assert! 'stop #:meta-level 1)))
(exit 0)
(spawn-keyboard-integrator)
(spawn-background)
;; (spawn-frame-counter)
(spawn-player-avatar)
(actor (react (assert (simple-sprite 0 50 50 50 50 (circle 50 "solid" "orange"))
#:meta-level 1)
(assert (simple-sprite -1 60 60 50 50 (circle 50 "solid" "green"))
#:meta-level 1)))
(actor (until (message (key-event #\q #t _) #:meta-level 1))
(assert! 'stop #:meta-level 1))
(module+ main (current-ground-dataspace (2d-dataspace)))

View File

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