2 player scoring selection
I'm trying to create a pong game where the ball can destroy floating objects. The problem I'm having is how to score it for 2 players. If the ball bounces of player 1's paddle and hits an object I'd like to get the points to player 1. If the ball bounces of player 2's paddle and hits an object I'd like to get the points to player 2. I've been trying to do two things that have not worked yet....track the direction of the ball if it is moving to the right it could score for player 1, if the ball is moving to the left it would score for player 2. That is the first method I tried. The 2nd method was to try to connect the score to whatever paddle the ball hit last...if it just bounced off of player 1's paddle it would score for player 1 until it hit player 2's paddle and then the ball would score for player 2 any time it hit a floating object until the ball hit player's 1 paddle, etc. Any ideas would be appreciated. Thanks in advanced.
Re: 2 player scoring selection
Your second idea (connecting the points to the last paddle hit) is very easy. When the ball hits a paddle, set a flag on the ball. If player 1 hits the ball, set the ball flag to ON. If player 2 hits the ball set the ball flag to OFF. Or you could use the toggle flag command. :D
Then when your ball hits an object that scores points, you have 2 conditions:
-If ball collides with object
+Ball Flag is ON
-->add points to player 1
-If ball collides with object
+Ball Flag is OFF
-->add points to player 2
Hope that helps,
Mobichan
Re: 2 player scoring selection
Mobichan,
Thanks a bunch...that was much easier than anything I was trying to do and it works great. I appreciate your help.