2 Runtime Functions and Classes
(require scratchy/runtime) | package: scratchy |
Runs a Scratchy program given a starting land. The
sprites in the land are drawn last to first in the order of
addition to the land (so the last added sprite is drawn under all
others, for example).
A land that holds sprites and connections to other
lands. One land is displayed at a time, and the displayed land can be
changed with the watch method.
Creates a land, given a procedure that gets connected lands when the Scratchy program starts. The get-lands callbacks for different lands can include each land in the other’s lists. The lands available in the Scratchy world include the all of the lands reachable from the one given to run.Switches the Scratchy world view to this land.
A sprite implemented by the sprite% class is a
character in the Scratchy world. Each sprite has an image, a position
on the screen (where the origin is in the center of the Scratchy world
and positive Y-values correspond to north), a scale, an orientation
(in degrees), and an optional cartoon bubble.
The sprite’s public methods are all thread safe, and they work by
synchronizing with the eventspace in which Scratchy is run.
constructor
(new sprite% [land land] [image image] [ [x x] [y y] [key-callback key-callback] [mouse-callback mouse-callback] [message-callback message-callback]]) → (is-a?/c sprite%) land : (is-a?/c land%) image : convertible? x : real? = 0 y : real? = 0
key-callback : (boolean? (or/c symbol? char?) . -> . any) = void mouse-callback : (boolean? real? real? . -> . any) = void message-callback : (any/c . -> . any) = void Creates a sprite that is initially in land.The key-callback function is called in a fresh thread for any key press or release in the Scratchy world, where the initial boolean argument is #t for a key press and #f for a key release.
The mouse-callback function is called in a fresh thread for a mouse click on the sprite.
The message-callback function is called in a fresh thread for a tell or broadcast call.
Moves the sprite in the direction of its current orientation.Changes the sprite’s location in the X direction.Changes the sprite’s location in the Y direction.Sets the sprite’s location in the X direction.Sets the sprite’s location in the Y direction.Gets the sprite’s location in the X direction.Gets the sprite’s location in the Y direction.Changes the sprite’s orientation by turning it counter-clockwise.Sets the sprite’s orientation.
method
(send a-sprite change-size amount) → void?
amount : real? Changes the sprite’s size as a factor of its original size by adding amount to the current factor.Makes the sprite visible.Makes the sprite invisible.
method
image : convertible? Sets the sprite’s image.Sets the sprite’s speech balloon to show v.Removes the sprite’s speech balloon, if any.Calls other-sprite’s message callback with v in a new thread.Returns the sprite’s land.