|Liberty BASIC Help Online
Flushing Sprite Graphics
In Liberty BASIC graphicboxes and graphics windows, the drawings are lost if the window is covered by another window, or if the window is minimized. To make drawings "stick", use the FLUSH command. The FLUSH command is used in conjunction with DELSEGMENT, DISCARD, REDRAW, and CLS.
In the following example, the graphicbox is filled with yellow. The second line commands Liberty BASIC to remember this drawing operation, and to repaint the graphicbox when needed, so that it is always filled with yellow. Without the FLUSH command, the graphicbox reverts to its default color in any areas that were covered by another window, and the entire graphicbox reverts to its default color when the window was minimized. The FLUSH command insures that it will always be yellow.
print #w.g, "down; fill yellow";
print #w.g, "flush";
FLUSHING SPRITE GRAPHICS
A simple FLUSH command will not work to flush graphics drawn with sprite commands. It is possible to flush a sprite-filled graphicsbox or graphic window. It first requires a command to:
GETBMP BMPNAME X Y WIDTH HEIGHT
The GETBMP comand must be followed by a DRAWBMP command that draws the named bitmap on the window or graphicbox in the same location. It can then be FLUSHed. It looks like this in a program:
print #w.g, "getbmp KeepIt 0 0 300 200";
print #w.g, "drawbmp KeepIt 0 0; flush";
DON'T FLUSH EVERY FRAME OF A SPRITE ANIMATION! The "flush" command consumes memory.
The graphicbox can be updated easily when needed with the DRAWSPRITES command. If the sprites are part of an animated display, each frame of animation can be flushed, but it is important to remove old segments from memory. It is rarely necessary to flush animated graphics, because the display can be refreshed easily, and the operations to flush and delete segments will slow down the animation.
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/