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.

2D All the way! / Sprite Collision Help....

Author
Message
Flindiana Jones
21
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Bosnian Power
Posted: 1st Dec 2005 02:07
I can't seem to get the built in DarkBasic sprite collision to work. I dont care particularly about pixel perfection, I just want any sort of collision I can get. I try "sprite collision(49+i, 0) and it always returns 0, even when the sprite is on top of and under other sprites. Any ideas of what's wrong?

Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 1st Dec 2005 03:04 Edited at: 1st Dec 2005 03:05
Why 49+i?
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Dec 2005 10:49
I just use a for/next loop to check all the sprites against the players sprite and it works fine (and seems to be just as fast)... i've never used zero.
Flindiana Jones
21
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Bosnian Power
Posted: 1st Dec 2005 15:03
49+i is the sprite number of the bullet I am currently checking in the while loop. And I have tried your approach, Grog, but that returns 0 also.

Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 1st Dec 2005 15:42
Could you show some more code?, maybe the mistake is somewhere else...
Flindiana Jones
21
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Bosnian Power
Posted: 1st Dec 2005 20:48 Edited at: 2nd Dec 2005 00:20
Here's the complete source + media.

Peter H
22
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 2nd Dec 2005 00:46 Edited at: 2nd Dec 2005 01:41
Here, i made a simpler form of the problem...

i've attatched a source file along with a image it needs to run... the image is 10*10 pixels...

why in the world does it say that sprite 1 is colliding with sprite 2 when they are on opposite sides of the screen and both of them are only 10*10????



"We make the worst games in the universe..."
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 2nd Dec 2005 01:02
Peter_ , i work sprites in a diferent way... i don't use paste sprite, actually, i didn't even knew it existed. I just used sprite command to reposition it. Doing so, works fine the collision system.

Peter H
22
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 2nd Dec 2005 01:23 Edited at: 2nd Dec 2005 01:25
...

wow...
whole new worlds have been opened to me.

i thought that the sprite command was only for creating sprites... (as did flynn)

"We make the worst games in the universe..."
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Dec 2005 10:23 Edited at: 2nd Dec 2005 10:26
Quote: "why in the world does it say that sprite 1 is colliding with sprite 2 when they are on opposite sides of the screen and both of them are only 10*10????"


It's because both sprites are in the same position.



"paste sprite" is like using a stamp (the kind with ink). It stamps to the screen whatever the sprite currently looks like... but any sprite commands like collision only look at the sprites... not the stamps to the screen.

Paste sprite is good for quickly making tile maps without the slowdown of having 5000 sprites on the screen at the same time. The less sprites we use the faster everything goes.

Flindiana Jones uses paste sprite too... once it's changed to normal sprites the collision should work properly.
Chilled Programmer 420
20
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 2nd Dec 2005 11:05
i use the MOVE SPRITE spriteno, distance

this moves the specified sprite a specified differance along its leading edge

that is the top edge when they load

LIVE LIFE LOUD LOVE MUSIC
rock, metal, punk, emo, ska, reggae, indie, goth, 70's rock, 80's rock, death metal, poppunk, grunge
***caffine, weed, programming and rock addict***
Flindiana Jones
21
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Bosnian Power
Posted: 2nd Dec 2005 15:31
Thanks so much Grog and Zergei! It works now... they should say something about that in the help files.

Peter H
22
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 2nd Dec 2005 15:53 Edited at: 2nd Dec 2005 15:54
yeah, what's funny is i've made entire 2D games without sprite collision (like Burnt Soil)

it would have saved me a lot of pain if they had explained this in the help files...

"We make the worst games in the universe..."
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Dec 2005 21:58
Quote: "Thanks so much Grog and Zergei! It works now... they should say something about that in the help files."


Np. Yeah if they change the information on paste sprite to include my stamp analogy I think it'd help people to understand paste sprite better.

Login to post a reply

Server time is: 2026-07-11 03:56:13
Your offset time is: 2026-07-11 03:56:13