Another option is to arrange that there is only ever a single call to big-bang and there's a top-level data-type for the different modes of the game:
World = EditorWorld | PlayerWorld And when the Editor is ready it returns a Player. This can be a bit awkward because of the need for a top-level dispatch. It is slightly nicer in lux ( https://github.com/jeapostrophe/lux/blob/master/scribblings/lux.scrbl ) for a few reasons: First, when the simulation ends, the window closes. Second, the Word is more like an object that has its own tick/etc functions so you don't need the dispatch at the top. Third, when `fiat-lux' is called from within a call to `fiat-lux' then the INNER call takes over the window/gui/etc of the OUTER call. This is especially nice because when the INNER call does "end" then the value is returned to the call. If you wanted to do that in big-bang, you'd need to convert your program to CPS. Here's a simple demo that uses 2htdp's images but doesn't exploit the inner calling https://github.com/jeapostrophe/lux/blob/master/examples/val-demo.rkt And here's another one that uses the dc directly but has the inner calling thing: https://github.com/jeapostrophe/lux/blob/master/examples/spin.rkt lux is definitely more complicated because I expose the input event objects from Racket directly, but it's fairly painless to convert a big-bang program to use it. Jay On Sun, Jun 21, 2015 at 1:18 PM, Matthias Felleisen <matth...@ccs.neu.edu> wrote: > > It used to be that when you ran a program like this > > ;; isl+ > (require 2htdp/image) > (require 2htdp/universe) > > (big-bang 10 > (to-draw (lambda (x) (circle (+ (* 10 x) 20) 'solid 'red))) > (on-tick sub1) > (stop-when zero?)) > > The window would shut down. But people wanted it to stay > open so that they could see the final score of their games etc. > > I guess I could add a close-on-stop clauses for programmers > such as your son but it sounds almost like he's ready to move > on to racket proper, as in use the Windowing API directly. > > He may also be interested in Jay's variant of 'universe', > which is faster (and comes with sound) or Neil's (experimental) > 3D version. I conjecture that they are both more open to extensions > than my teaching versions > > -- Matthias > > > > > > On Jun 21, 2015, at 12:33 PM, John Carmack wrote: > >> My son's game has a level editor as well as a game loop, and we switch >> between them. However, each new big-bang call creates a new window, leaving >> the previous ones inert on the screen. How can we close the windows? >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to racket-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy http://jeapostrophe.github.io "Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great." - D&C 64:33 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.