UPDATING THE DISPLAY

The DRAWSPRITES command updates the display, causing all
VISIBLE sprites to be drawn at their current LOCATIONS,
moving them if the SPRITEMOVEXY command has been issued.
They will display in their current SCALE and ORIENTATION.
This command must be given each time  it is necessary to draw
another frame of animation. Sprite attributes may be changed
in between the DRAWSPRITES commands, including their location,
orientation, and scale.  If the background image is to be
moved, the BACKGROUNDXY command must be issued before the
DRAWSPRITES command.

print #w.g, "drawsprites";

DRAWING WITH GRAPHICS COMMANDS
After the display has been updated with the DRAWSPRITES
command, graphics may be drawn with regular Just BASIC
graphics commands, like LINE, CIRCLE, BOXFILLED, etc.  These
commands must be reissued after each DRAWSPRITES command.
Just BASIC graphics commands should be used sparingly,
because this may result in flickering images.

To cause Just BASIC graphic entities to become a permanent
part of the background the program must use the GETBMP
command, and then the BACKGROUND command to reset the
background.  See the section on backgrounds for more
information.

COLLISION DETECTION
Most games require some form of collision detection, to
ascertain when two sprites have touched.  Just BASIC does
this automatically!  The SPRITECOLLIDES command is used with
INPUT to get a string with names of sprites that overlap the
current frame of the sprite named.  The INPUT statement can
be avoided if the list receiver variable is placed inside the
quotation marks for the SPRITECOLLIDES command.  The sprite
names are returned in a single string with spaces between
them.

    print #w.g, "spritecollides smiley";
    input #w.g, list$
OR
    print #w.g, "spritecollides smiley list$";

In the following example, the first line reports that "smiley"
collided with "smiler", "smiled", and "smiles" during that
frame of animation.  The second line reports that "smiley"
collided with "smiler" and "smiles" during that frame of
animation.  The third line reports that "smiley" collided
only with the sprite named "smiler" during that frame of
animation.  The fourth line reports that "smiley" did not
collide with any other sprites during that frame of animation.

    list$ = "smiler smiled smiles"
    list$ = "smiler smiles"
    list$ = "smiler"
    list$ = ""

Collision detection provided by Just BASIC uses the entire
sprite image, all the way to the corners, to determine
collisions.

INVISIBLE SPRITES AND COLLISIONS
Invisible sprites still trigger collisions.  If a sprite is to
be out of action for a time, in addition to being made invisible,
it should also be located to a spot outside the active viewing
area.  Invisible sprites may be used to set up a screen area for
collision detection.  For instance, if it is necessary to know
when a sprite is touching a doorway, an invisible sprite can be
placed at that spot on the screen so that it can be checked for
collisions.

REMOVING SPRITES
It is sometimes necessary to remove sprites from the collection
of sprites so that they no longer appear and so that they no
longer trigger collisions. This might be done after a sprite
collides with another sprite, so that it is no longer in play in
the game. Remove sprites with the REMOVESPRITE command.

    print #w.g, "removeSprite smiley"

DETECT SPRITE LOCATION
The SPRITEXY? command retrieves the current location of a sprite.
If a CENTERSPRITE command has been issued, the x, y location
returned indicate the center of the sprite, otherwise they
indicate the upper left corner. Just like the SPRITECOLLIDES
command, it can have two forms.  It can be followed by an input
statement, with two receiver variables for the x and y
coordinates of the sprite, or the receiver variables can be
included inside the quotation marks of the SPRITEXY? command:

    print #w.g, "spritexy? smiley"
    input #w.g, x, y
OR
    print #w.g, "spritexy? smiley x y"

IMPORTANT REMINDER!
To avoid flickering, sprite animation is done invisibly, in
memory.  A frame of animation is built entirely off-screen.  A
frame of animation is displayed on the screen only when the
command DRAWSPRITES is called.  For each frame of animation,
perform all functions to set the background image, and to set or
change a sprite's properties, then call the DRAWSPRITES command.

Sprite graphics are temporary.  To learn about making sprite
graphics remain in a graphicbox or graphics window, even if the
window is covered or minized, read Flushing Sprite Graphics.