Hi, I wrote a basic sprite collision example that uses eXtends commands but the weird thing is that it only works for bmps.
Here it is
Rem Project: Extends Sprite Collision
Rem Created: Saturday, May 01, 2010
Rem ***** Main Source File *****
// demonstrate pixel perfect sprite collision using extends
sync on : sync rate 60
// declare variables
type ball
x as integer
y as integer
xspeed as integer
yspeed as integer
num as integer
endtype
collision as integer = 0
red as ball
green as ball
// variables for red
red.x = 10 // x position
red.y = 100 // y position
red.xspeed = 1 // x speed
red.yspeed = 1 // y speed
red.num = 3 // set the sprite number
// variables for green
green.x = 400 // x position
green.y = 180 // y position
green.xspeed = 0 // stationary
green.yspeed = 0 // stationary
green.num = 4 // set the sprite number
// load images
set image colorkey 0,0,0
load image "greenball2.bmp",1,1 // this preserves pixel perfect quality
load image "redball.bmp",2,1
do
cls // clear screen
ink rgb(0,0,240),0
box 0,30,640,480
// create the sprites
sprite red.num, red.x, red.y, 2
sprite green.num, green.x, green.y, 1
// // turn on transparency
// set sprite alpha red.num, 100
// set sprite alpha green.num, 100
// move the red ball using arrowkeys
if upkey()=1 then dec red.y, red.yspeed // move the ball up
if downkey()=1 then inc red.y, red.yspeed // move the ball down
if leftkey()=1 then dec red.x, red.xspeed // move the ball left
if rightkey()=1 then inc red.x, red.xspeed // move the ball right
// prepar the sprites for collision
spr prepare collision red.num
spr prepare collision green.num
// test for collision
collision = spr get collision(red.num, green.num, 0) // the zero is a flag that tests for overlapping pixels
// print the collision results and instructions
text 0, 0, "Use the arrowkeys to move the red ball"
text 0, 10, "Sprite Collision = " + str$(collision)
sync // refresh
loop
You'll have to insert your own media into the example, unfortunately the uploader doesn't like my files so I can't produce the files I used.
Hope this helps
A clever person solves a problem, a wise person avoids it - Albert Einstein