I've just finished this and seeing as i'm a nice person and all that rubbish here you go. I'm sure someone will find it useful
SET IMAGE COLORKEY 255,0,255
sync on : sync rate 0
set text font "arial" : set text size 16
set text to bold : set text transparent
rem Nice backdrop
rem load bitmap "parchment.jpg"
rem Produce Title
set display mode 640,480,32
ink rgb(255,255,255),0
load image "ship.bmp",1
sprite 1,0,20,1
sprite 100,0,20,1
create bitmap 3,640,480
create bitmap 2,640,480
rem Create an array to hold pixeldatas
bitsperpixel=bitmap depth()/8
workA = make memory(640*480*bitsperpixel)
maskmem = make memory(640*480*bitsperpixel)
fill memory workA, 384, 640*480*bitsperpixel
fill memory maskmem, 84, 640*480*bitsperpixel
lock pixels
pitch=get pixels pitch() : ptr=get pixels pointer()
workAptr=workA : linesize=640*bitsperpixel
unlock pixels
rem daves annoying mask test
shipxpos=350
shipypos=100
rem copy mask object to maskmem
imagenumber=1
enemyx=100
enemyy=100
boxcheckwidth=32
boxcheckheight=32
clboxy=20
clboxx=0
maskboxcheckwidth=36
maskboxcheckheight=32
rem Main loop
do
set current bitmap 0
set cursor 00,40
print screen fps(),"Y",shipypos," X",shipxpos
paste sprite imagenumber,enemyx,enemyy
paste sprite 100,shipxpos,shipypos
Gosub _GrabMaskArea
Gosub _GrabCollisionArea
Gosub _DrawMemoryToScreen
Gosub _xorCollisionData
if leftkey()=1 then shipxpos=shipxpos-1
if rightkey()=1 then shipxpos=shipxpos+1
if upkey()=1 then shipypos=shipypos-1
if downkey()=1 then shipypos=shipypos+1
sync
rem End loop
loop
rem Free memory
delete memory workA
delete memory maskmem
REM
REM ********** SUBROUTINES
REM
_GrabMaskArea:
REM grab mask area
set current bitmap 3
paste image 1,0,0
lock pixels
pitch=get pixels pitch() : ptr=get pixels pointer()
workAptr=maskmem : linesize=640*bitsperpixel:widthsize=maskboxcheckwidth*bitsperpixel
for y=0 to maskboxcheckheight
copy memory workAptr, ptr, widthsize : inc workAptr,linesize : inc ptr,pitch
next y
unlock pixels
Return
_GrabCollisionArea:
REM grab collision area
clboxy=shipypos
clboxx=shipxpos
set current bitmap 2
paste image imagenumber,enemyx,enemyy
lock pixels
pitch=get pixels pitch() : ptr=get pixels pointer()
workAptr=workA : linesize=640*bitsperpixel:widthsize=boxcheckwidth*bitsperpixel
for y=0 to boxcheckheight
copy memory workAptr, ptr+(clboxy*linesize)+(clboxx*bitsperpixel), widthsize : inc workAptr,linesize : inc ptr,pitch
next y
unlock pixels
Return
_DrawMemoryToScreen:
REM Draw Memory to screen
set current bitmap 0
lock pixels
workAptr=worka
pitch=get pixels pitch()
linesize=pitch
ptr=get pixels pointer()
for y=0 to boxcheckheight
copy memory ptr,workAptr, widthsize
inc workAptr,linesize
inc ptr,pitch
next y
unlock pixels
Return
_xorCollisionData:
REM xor collision data
forceexit=0
linesize=640*bitsperpixel
for cheight=0 to maskboxcheckheight-1
counter=1
for cwidth=0 to maskboxcheckwidth-1
objshape=maskmem
collarea=worka
inc objshape,(cheight*linesize)+(cwidth*bitsperpixel)
inc collarea,(cheight*linesize)+(cwidth*bitsperpixel)
inc counter,1
x1 as byte
x2 as byte
x1=*objshape
x2=*collarea
collide = x1 && x2
rem if collide=0 then print "O";
if collide>0 then print "collide":forceexit=1:exit
next cwidth
if forceexit=1 then exit
next cheight
Return