DRAWSPRITES

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

This command updates the sprite display and is therefore mandatory when using sprites. All the visible sprites will be drawn on the BACKGROUND. Without this command you will not see the sprites or the BACKGROUND.

Syntax

  1. print #WindowHandle.controlHandle, "Drawsprites"
  2. #WindowHandle.controlHandle "Drawsprites"

Hints

DRAWSPRITES is mostly used in timed loops with the help of the TIMER.

Example

BMP files that will be used in the example below:

This example uses the images from above. Save them to a folder of your choice and run this code from the same folder.

    NOMAINWIN
    LOADBMP "BMP1","sprite_jb_back.bmp"
    LOADBMP "BMP2","sprite_jb_guy_1.bmp"

    Open "Just BASIC - Sprite Demo - Drawsprites" For Graphics_nsb_nf as #main
    #main "Trapclose [quit]"
    #main "Background BMP1"
    #main "AddSprite player BMP2"

    ' go to the redraw branch every 56 milliseconds
    Timer 56,[redraw]
    Wait

[redraw]
    ' the Drawsprites command is issued every 56 milliseconds
    #main "Drawsprites"
    Wait

[quit]
    Timer 0
    Close #main
    UNLOADBMP "BMP1"
    UNLOADBMP "BMP2"
    End

Useful Procedures

' Place a useful function or sub using this keyword here