5.92
(require class/universe) | package: base |
procedure
(big-bang obj) → World
obj : World
An object-oriented version of big-bang.
The given world object should provide some of the methods descibed below. For any methods that are not provided, DrRacket will use a default behavior. The world must at least provide a to-draw method.
Here is an example world program that counts up from zero:
#lang class/0 (require class/universe) (require 2htdp/image) (define-class counter-world% (fields n) (define (on-tick) (new counter-world% (add1 (send this n)))) (define (tick-rate) 1) (define (to-draw) (overlay (text (number->string (send this n)) 40 "red") (empty-scene 300 100)))) (big-bang (new counter-world% 0))
Produces the name of the world.
Tick this world, producing a world.
syntax
key : key-event?
Handle the keystroke key, producing a world.
syntax
(send a-world on-release key)
key : key-event?
Handle the key release key, producing a world.
syntax
x : integer?
y : integer?
m : mouse-event?
Handle the mouse event m at location (x,y),
producing a world.
Draw this world, producing an image.
Produce the rate at which the clock should tick for this world.
If this method produces true, the world program is shut down.
syntax
(send a-world check-with)
If this method produces true, the world is considered a
valid world; otherwise the world program signals an error.
If this method produces true for the initial world,
DrRacket enables a visual replay of the interaction.
If this method produces true for the initial world,
DrRacket displays a seperate window in which the current state is
rendered.
procedure
(universe obj) → Universe
obj : Universe
An object-oriented version of universe.
The given universe object should provide some of the methods descibed below. For any methods that are not provided, DrRacket will use a default behavior. The universe must at least provide a on-new and on-msg method.
Signal that the given new world has joined the universe, producing a bundle.
Signal that the given world has sent the given message to the
universe, producing a bundle.
Tick this universe, producing a bundle.
Produce the rate at which the clock should tick for this universe.
syntax
(send a-universe on-disconnect iw)
iw : iworld?
Signal that the given world has left the universe, producing a bundle.
syntax
(send a-universe check-with)
If this method produces true, the universe is considered a
valid universe; otherwise the universe program signals an error.
Produce a string representation of the universe.
If this method produces true for the initial universe,
DrRacket displays a seperate window in which the current state is
rendered.