Archived

This topic is now archived and is closed to further replies.

Flare

Sprite collision using DelphiX

Recommended Posts

Flare    122
Hello! I''m working on a 2D hockey game in Delphi using the GDK DelphiX and I have a problem I can''t solve: I have made it possible for the player (there is only one at this stage) to pick upp the puck by skating over it, and that was pretty easy. Next step is to make the player shoot the puck by pressing a button, and here comes my problem: since I use the collision detection to tell if the player sprite has collided with the puck sprite in order to get the player to pick up the puck, I have a hard time getting him to let it go, because everytime the puck passes "through" the player sprite it sets off the collision procedure and makes the player pick up the puck again. If I, on the other hand, turn the collision detection off when I press the shot button then the player will shoot the puck, but since I have turned the collision detection off, he won''t be able to pick it up again, and I haven''t figured out how to activate it again. I hope someone understands what I''m after although the explanation is a little fuzzy! Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites
smart_idiot    1298
Maybe the puck should have a flag to determine weather the puck can be picked up?

When the player picks up the puck, set the flag. When the puck is some distance away from the player, the flag can get reset, and the puck can only be picked up when the flag isn't set and he isn't that last player to pick up the puck.

I don't use Delphi, so I can't help you code it. I'm sure you can figure it out, though.

[EDIT: Stupid mistakes. Took me long enough to find them. ]

[edited by - smart_idiot on May 2, 2002 3:28:27 PM]

Share this post


Link to post
Share on other sites
Jason Zelos    211
Perhaps you could record the direction the puck is moving in relation to the player, if its going away then it cannot be picked up otherwise it can (assuming the puck speed is greater than the players).

,Jay

Share this post


Link to post
Share on other sites