Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Sprite collision - "sprite exist()" not working?

Author
Message
Jibbed
21
Years of Service
User Offline
Joined: 5th Mar 2004
Location:
Posted: 29th Mar 2004 06:23 Edited at: 29th Mar 2004 06:27
I have the following code to check whether a series of sprite numbers (4 to 10) are colliding with a bullet. This code is ran whenever one or more bullets are on the screen:



The bullets are not sprites themselves but basic 2D lines that DB draws. Their properties (x, y and speed) are held in an array. I have a function called "CheckBulletEnemyCollision()" that checks whether the position of the bullet matches that of the sprite number that is passed into it.

This works as expected the first time the enemy is on the screen, i.e. it says enemy killed when a bullet collides with it. But the second/third etc. time the enemy sprites are on the screen the code returns "sprite number ... doesn't exist"

Why could this be. Could it be because when the enemy is off screen I destroy the sprite? This crossed my mind but when the enemy is due to come back on screen I use the "sprite 4,x,y,imagenumber" command therefore re-making the sprite and making it "exist".

Is there a problem with the sprite exists function, or with my code? Thanks for anyones help.

Cheers,
Jibbed.

PS. Lee Bamber is actually teaching me this stuff in uni at the mo but haven't had a chance to ask him yet

Login to post a reply

Server time is: 2025-05-23 04:34:15
Your offset time is: 2025-05-23 04:34:15