Sprite collision using DelphiX

Started by
1 comment, last by Flare 21 years, 11 months ago
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!
Advertisement
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]
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
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

This topic is closed to new replies.

Advertisement