GRAPHICS AND SOUND

    RC BASIC uses a concept used in sdlbasic and borrowed from AMOS on the Amiga about using virtual render targets to draw on.  In RC BASIC these virtual render targets are called canvases.  You must have at least one canvas open in order to draw anything in a window.  Look at the following:

    WindowOpen ( 0, "TEST WINDOW", 100, 100, 640, 480, 0 )
    CanvasOpen ( 0, 640, 480, 0, 0, 640, 480, 0 )

    The above example is a simple example of opening a window and canvas so you can start drawing.  The first line opens a 640x480 window at coordinate (100, 100).  The second line opens canvas 0 as a 640x480 render target and sets its viewport to 640x480 area starting at (0, 0) in the window.  Now that a window and canvas are open you can start drawing.  Once you are done drawing you need to call UPDATE to display what you have drawn.  Look at the following:

    WindowOpen ( 0, "TEST WINDOW", 100, 100, 640, 480, 0 )
    CanvasOpen ( 0, 640, 480, 0, 0, 640, 480, 0 )

    SetColor( RGB ( 255, 255, 255 ) )
    Box ( 20, 20, 60, 60 )

    Update ( )

NOTE: UPDATE() ALSO UPDATES EVENTS (KEYBOARD, JOYSTICK, ETC.) FOR THE WINDOW ON EACH CALL

    This example draws a white rectangle to the screen.  The first two lines are pulled from the previous example.  The third line sets the color used for drawing.  The fourth line draws a rectangle from coordinate (20, 20) to coordinate(60, 60).  And the last line shows what you just drew on the screen.  RC BASIC allows a total of 8 windows and 16 canvases with a total of 4096 images that can be loaded in your program.

    Sound in RC BASIC is handled the same way as canvases or images.  You can load a sound into slot and play the sound on a selected channel.  Look at the following:

    LoadSound ( 0, "MYSOUND.WAV" )
    PlaySound ( 0, 1, 3 )

    The above code will load a sound into sound slot 0.  The second line plays the sound in channel 1 for 3 loops.  You can have a total of 1024 sounds loaded in your program.  For music and video you can only load one and choose to play it or delete it from your programs memory and load another.  Look at the following:

    LoadMusic ( "MYMUSIC.MP3" )
    PlayMusic ( -1 )

    The above code loads a music track.  The second line tells the music to play infinitely.  To change music tracks you would first call DELETEMUSIC and then simply call LOADMUSIC again.