|
-
Mar 14th, 2009, 03:52 AM
#1
Thread Starter
Hyperactive Member
-
Mar 16th, 2009, 10:19 AM
#2
Re: Pong in 2D - XNA GS2.0
Nice! Sounds like you just need a better collision detection routine.
If I were doing that, I'd just use simple positional information. Is the ball's X position roughly matching the paddle's X position? If so, determine the Y positions of each. If the ball's Y position is anywhere within the paddle's Y position range, perform the deflection. Otherwise, continue on the current trajectory.
-
Mar 17th, 2009, 01:11 AM
#3
Thread Starter
Hyperactive Member
Re: Pong in 2D - XNA GS2.0
I've been considering this, though the problem with this is that the ball might at times move "past" the paddle. (EG: ball X = 34, paddle left + paddle width = 30, ball moves at x - 5, the ball's position will now be 29) This should never happen, though if it does, the ball should bounce back instead of fall off the screen.
The alternative would be to leave it as it is. In the slightest of times it will seem odd, but I don't think there's much I can do here.
-
Mar 27th, 2009, 04:26 PM
#4
Re: Pong in 2D - XNA GS2.0
Have you tried putting your out-of-bounds section of the Else If structure before the part that detects for Intersection?
You could fine-tune it then since it'll detect and process a missed ball using your given parameters (If ballPosition.X < paddleLeft.X + (paddleLeft.Width * 0.5)) before it processes a rebounded ball that was just barely clipped by the paddle.
The next step would be to start implementing simple vector math to handle angles and where exactly it intersects on the paddle (closer to the edge rebounds at a steeper angle).
Then work on ball-speed. 
The hardest thing I had to cope with for my Tetris game I made with XNA was making the game responsive and the controls usable once the speed started to get on the verge of crazy.
-
Mar 30th, 2009, 01:24 AM
#5
Thread Starter
Hyperactive Member
Re: Pong in 2D - XNA GS2.0
That's a very good suggestion. (Can't believe I didn't think of that! ) I'll try swapping the code and see how it works out.
As for the vector math: I'll probably have a look at that in a couple of days, though right now I'm just using simple 45 degree angles. It's way easier!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|