Ozapell Basic Learn Programming #8

Graphics are simple with Ozapell Basic.

First, the program must switch from text mode to graphics mode. In text mode, the screen is mapped as 40 x 22 text characters. In graphics mode, the screen is mapped as 320 x 180 pixels.

These two lines switch to graphics mode:



Ozapell Basic will automatically revert back to text mode when the program ends.

The following four lines can be used to draw a pixel on the screen:





In this example, a green pixel will be displayed at coordinates 32,32 on the screen. The upper-leftmost corner is 0,0. The bottom-rightmost corner is 319,179.

When working with graphics mode, be sure to end your program waiting for a keypress. Otherwise, Ozapell Basic will return to text mode and the graphics will not be visible. Here’s a simple example:




In this example, the program will loop until a key is pressed on the keyboard.

A bitmap image file can be loaded and displayed in graphics mode.

Here is an example of loading a bitmap file called DEMO.BMP. Note: all data files must be copied into the Ozapell Basic folder found in the Documents folder to be accessible by Ozapell Basic.






In this example, DEMO.BMP is loaded into the array called MYBITMAP. (Note: Ozapell Basic does not accept extensions or file paths. Only the filename without the extension is used.) RESULT will contain the number of pixels in the image which is also the number of entries in the array. WIDTH will contain the width of the image loaded. This value is used to display the image later.

To draw the image on the screen while in graphics mode, ARRAYDRAW is used:






In this example, the image contained in the array MYBITMAP is displayed in the upper-leftmost corner of the screen.

By default, all display subroutines draw on the screen immediately which is slower. For faster graphics or to compose complex scenes before displaying the end result, use the offscreen buffer. SCREENHIDE stops displays to the screen and, instead, displays all output to the offscreen buffer. SCREENSHOW displays the offscreen buffer to the screen and returns to the default of displaying immediately to the screen.

Ozapell Basic on Steam


Ozapell Basic Learn Programming #8

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s