Developer postOriginal post (opens in a new tab)

Version 0.6 - Sprite Collision Detection

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.

https://www.youtube.com/watch?v=j1wqlctmnq8

Have fun!