Just been messing around with sprites and noticed a couple of odd things going on with SPRITE COLLISION.
I've included some code so you can see what I mean.
If you overlay one small sprite on top of another larger one then try to use x=sprite collision (
sprite under mouse pointer,0). No matter what the you do, it only detects the big sprite underneath. Yet if you use sprite collision(sprite under mouse pointer,small sprite) it detects the collision. Its hard to explain well, try the code and youll see what I mean.
Also, if you take a sprite and rotate it, then try to detect a collision - no chance. It seems like DBP rotates the sprite but does not rotate the collision map for that sprite. In the example youll see what I mean if you move the mouse past the bottom right of the blue bar.
Are these just bugs or is there a simple way to work around them?
create bitmap 1,200,200
ink rgb(255,0,0),0:box 0,0,100,100:rem big red box
get image 1,0,0,100,100
ink rgb(0,255,0),0:box 0,0,50,50:rem small green box
get image 2,0,0,50,50
ink rgb(0,0,255),0:box 0,0,100,25:rem blue oblong to be rotated
get image 3,0,0,100,25
get image 4,0,0,1,1 :rem for mouse pointer to detect collisions
delete bitmap 1
sync on
sync rate 60
do
sprite 4,mousex(),mousey(),4
sprite 1,0,0,1:set sprite priority 1,0:rem big red box
sprite 2,25,25,2:set sprite priority 2,1:rem small green box
sprite 3,200,200,3:rotate sprite 3,270:set sprite priority 3,0:rem blue rectangle
if sprite collision(4,2) and mouseclick()=1:rem checks for hit on green box
text 20,160,"HIT!"
sync
repeat
until mouseclick()=0
endif
coll=sprite collision(4,0)
text 20,150,str$(coll)
sync
loop