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

Author
Message
Zero Blitzt
21
Years of Service
User Offline
Joined: 18th Jan 2004
Location: Different Stages
Posted: 14th Apr 2004 23:46
OK, I have my game coming along nicely. I have my robots controlled under 1 variable, "robo". If I set sprite collision on for them (robo,robo), then it acts as if they are colliding with themselves. I want them to collide with the other robots, not themselves... heres an example:

and are controlled under the variable robo.
Sprite collision is set on for robo.
thinks its colliding with itself, so does
I want and to seperate from eachother if they are colliding.

It's a tough one in my opinion, sort of like a chain reaction problem.


GameXaero forums - www.t4e0.4cybiko.com
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 15th Apr 2004 00:35 Edited at: 15th Apr 2004 00:38
u have to do


sprite 1,x,y,image
sprite 2,x,y,image

sprite collision(1,2) then stop

U have to separate them cuz if not you are saying to the program if collision is with sprite 1 and sprite 1 then stop,and that's the problem

CURRENT PROJECT: RETRO PAC-MAN
Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 15th Apr 2004 12:35
Or Pincho showed me how to do this(I think it was he):

do
hitbyspritenunmber=sprite collision (1,0)
set cursor 333,20
print "hitbyspritenunmber",hitbyspritenunmber
loop


this will let you test which sprite is colliding with sprite 1, where sprite 1 is the one youre checking. If you use 0 as the second number then it checks to see if sprite 1 has collided with any sprite, which is very usefull I find....

GIve me more power!
Scouseknight
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 15th Apr 2004 13:01
One question I have with regard to sprites - does sprite hit(<sprite>,0) return a collection - for example, of a sprite is in collision with more than one other sprite.

That would be incredibly useful and save looping through all sprites you wish to check for.

That aside, I find sprite hit and sprite collision do the same thing in DBPro - sprite hit is meant to ignore transparent pixels but I haven't successfuly managed to get it to work - there is a pixel-perfect sprite collision routine from Freddix in the code snippets should you come across this problem too.

Code Stealer
21
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 15th Apr 2004 13:22
Scouseknight, there is a difference between sprtie hit and collision in DBpro. Im not sure how to define it though, I havent done enough experiment with it, but I think hit returns a value of 1 only the first time, whereas collision does it every time you check. Or something like that. Basically, I had it that I had a sprite that ran around when you hit the arrow keys, and I was trying some simple collision detection with it, and found that my sprite would get get locked in place when I used collision but would only jam for a short while if I used hit. Anyway, as I said Im not really sure what was happening, but there IS a difference...

GIve me more power!
Scouseknight
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 15th Apr 2004 13:59
Cheers - I'll have to have another crack at this - I might post an example of the problem I have with the sprite hit versus sprite collision when I get home.

comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 15th Apr 2004 22:49 Edited at: 15th Apr 2004 22:50
sprite hit and sprite collision are different in both language(DBC,DBPRO).Sprite hit, is when you want to check when the sprite just hit once the other sprite.Sprite collision is if u want to check thye collision continously.

CURRENT PROJECT: RETRO PAC-MAN
Scouseknight
21
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 15th Apr 2004 23:55
I think my confusion is based on the "Beginners Guide" book which has Sprite Hit down as pixels overlapping - must be referring to the DBC way.

Thanks for clearing that up!

Login to post a reply

Server time is: 2025-08-09 02:12:37
Your offset time is: 2025-08-09 02:12:37