Ozapell Basic Learn Programming #10

Sprite Collision Detection is easy with Ozapell Basic!

Switch to graphics mode:

MODE=1
SETMODE

Assuming a bitmap image file called BITMAP.BMP is in the Documents -> Ozapell Basic folder:

BITMAP=0
ARRAY=BITMAP
FILENAME=”BITMAP”
BITMAPLOAD
BITMAPWIDTH=WIDTH

The array BITMAP now contains all of the pixels for the image loaded. RESULT will return the number of entries (pixels) in the array. WIDTH will contain the width in pixels for the image.

ARRAY=BITMAP
WIDTH=BITMAPWIDTH
X=0
Y=0
ARRAYDRAW

This will draw the image in BITMAP at the upper, leftmost corner of the screen (0,0).

ARRAY=BITMAP
WIDTH=BITMAPWIDTH
X=0
Y=0
OWNER=100
ARRAYDRAWOWNER

Draws the image in BITMAP at 0,0 plus every pixel drawn is associated with the value in OWNER. (Pixels given the a negative value are transparent and will not be associated with an owner value.)

ARRAY=BITMAP
WIDTH=BITMAPWIDTH
X=0
Y=0
ARRAYDRAWCOLLIDE

RESULT will contain the highest owner value associated with any pixel that would be drawn over if ARRAYDRAW was used instead of ARRAYDRAWCOLLIDE. This value can be used to determine collisions such as walls, enemies and bonuses.

OWNER=100
OWNERCLEAR

All pixels (and owner data) with the owner value given in OWNER will be cleared from the screen.

Ozapell Basic on Steam

Advertisements
Ozapell Basic Learn Programming #10

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s