Hey guys, this is the first of probably many posts of mine...I'm relatively new to DB and I'm trying to program a large, open world 2-D game. The best explaination I have for it is a mix between pokemon and skyrim (pokemon in the way of camera position and sprite style and skyrim in terms of the story).
ANYWAYS...to the point, I'm having trouble with overlapping sprites. I want to use a generic subprocedure to check for collision between the main character and sprites like houses, trees, etc. The problem is, the sprites I want to check for collision for are sitting on grass which I'm loading as a sprite. If I try to load it as anything other than a sprite (such as an image) it draws to the screen at the wrong time and appears to flash when the character moves. I have a lot of code so I'll only put up what I think contains the problem.
checkhit:
IF NOT sprite hit(1, 0)=2 THEN : sn=sprite hit(1, 0)
IF sprite collision(1, sn)
jvelocity=0
endif
IF sprite collision(1, sn) AND ks=17
while sprite collision(1, sn)
y=y+3
delete sprite 1
sprite 1, x, y, imgnum
sync
cls
endwhile
wait key
uvelocity=0
jvelocity=0
endif
IF sprite collision(1, sn) AND ks=30
while sprite collision(1, sn)
x=x+3
delete sprite 1
sprite 1, x, y, imgnum
sync
cls
endwhile
wait key
lvelocity=0
jvelocity=0
endif
IF sprite collision(1, sn) AND ks=31
while sprite collision(1, sn)
y=y-3
delete sprite 1
sprite 1, x, y, imgnum
sync
cls
endwhile
wait key
dvelocity=0
jvelocity=0
endif
IF sprite hit(1, sn)=1 AND ks=32
delete sprite 1
sprite 1, x, y, imgnum
sync
cls
wait key
rvelocity=0
jvelocity=0
endif
return
As you can see, I told the program to only set 'sn' as the sprite the player was colliding with if 'sprite hit(1, 0)' didn't return a 2, which is the sprite number of the grass. The problem is, because the grass is below all of my sprites, the player will always be colliding with it, therefore sn will never be able to be set to 'sprite hit(1, 0).' I hope I have been clear in trying to explain my problem and I'd like to thank anybody who can help me in advance. If you need another piece of the code, please just tell me.
-Live to code-