• Advertisement
Sign in to follow this  

Pong Game: Technical Review And Specs

This topic is 763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

Okay, so I read this guide on gamedev.net, learned some basic things in SDL, and started for making my first game i.e. Pong.

I have some knowledge regarding keyboard events, collision detection, etc. So, I hope that its enough for starting out with making that game.

 

Well, before starting to write the I tried to figure our how my game would look, work, etc. I designed and graphics, and then spent approximately 30-45 minutes to figure out how the ball bounces.

 

This is what I figured out:

  • The ball object has a variable 'direction' which has value from 0 to 360. 0 being the top direction, 90 being the right direction, 180 being the down direction and 270 being the left direction.
  • The ball will have a 'forward' function with which It will move ahead in the direction which he is facing. I achieved this by using some trigonometry.
  • After some more thinking and trying I understood that: If the ball is moving in direction 'x' and collides with a horizontal surface (the walls) then his direction will change to (90 - x). Similarly if he collides with a vertical surface (the paddles), his direction will change to (360 - x).

Some problems/doubts which I have:

 

Capture.png

 

In the above image the ball collides with down edge of the paddle, what will happen? If the paddle has velocity in the downward direction then should the ball reflect?

 

Please tell me the correct physics with which the ball should work (not how to implement, I'll try to figure it out on my own). And also tell me if there are any flaws in my method.

 

P.S: What about the graphics of my game? Are they looking good or the color scheme is not fitting?

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

If you try to implement "correct" physics in Pong you're going to run into a very serious problem: the paddles use absolute motion based on player input.

 

That may not sound like much, but the issue arises when the ball is between the paddle and a wall and you put the squeeze on it. What should happen then?

 

Rather than going for realism, consider this:

 

IF the ball touches a paddle AND the ball's horizontal velocity is toward that paddle's end of the board THEN 'hit' the ball with the paddle (deflect it like you would from a wall)

 

This is inaccurate, but it's easy to implement and it plays nicely.

 

Consider using an x/y vector for the ball velocity instead of angle/speed. If nothing else it will make your 'bounces' cheaper; since your impact surfaces are all axis-aligned you'll only ever need to reverse a single axis on the velocity vector.

 

Example, if the ball's velocity is 4,3 and it hits the bottom wall then its velocity becomes 4,-3. If it then hits a paddle the velocity becomes -4,-3. And so on...

 

You may also want to slightly increase velocity on every impact, and possibly add a small fraction of the paddle's motion to the ball when the two come in contact.

 

Ultimately the implementation details are up to you. It's your own learning experience, so pursue what interests you.

Share this post


Link to post
Share on other sites

Please tell me the correct physics with which the ball should work
I would try to answer the question the other way around.

It's a game, people playing it want to have fun.

 

What is an interesting and fun way to let the ball react?

 

What about the graphics of my game? Are they looking good or the color scheme is not fitting?
It's different and interesting at least. I like it.

 

With the brown bat I have some problem with the black at the edges (top and bottom). Against the dark background, it's hard to see where the bat ends exactly. If playing with or near the edges of the bat is important, that is a disadvantage.

The green/yellow bat doesn't have that problem, the green is light enough.

 

The green/yellow bat however is not symmetrical. The yellow dot in the center is not exactly in the center of the bat vertically. If playing with the top side of the bat has a different effect then playing with the bottom side, people are going to have a hard time deciding where exactly the middle is.

The brown bat has that problem too, but less obvious.

Share this post


Link to post
Share on other sites

If you try to implement "correct" physics in Pong you're going to run into a very serious problem: the paddles use absolute motion based on player input.
 
That may not sound like much, but the issue arises when the ball is between the paddle and a wall and you put the squeeze on it. What should happen then?
 
Rather than going for realism, consider this:
 
IF the ball touches a paddle AND the ball's horizontal velocity is toward that paddle's end of the board THEN 'hit' the ball with the paddle (deflect it like you would from a wall)
 
This is inaccurate, but it's easy to implement and it plays nicely.
 
Consider using an x/y vector for the ball velocity instead of angle/speed. If nothing else it will make your 'bounces' cheaper; since your impact surfaces are all axis-aligned you'll only ever need to reverse a single axis on the velocity vector.
 
Example, if the ball's velocity is 4,3 and it hits the bottom wall then its velocity becomes 4,-3. If it then hits a paddle the velocity becomes -4,-3. And so on...
 
You may also want to slightly increase velocity on every impact, and possibly add a small fraction of the paddle's motion to the ball when the two come in contact.
 
Ultimately the implementation details are up to you. It's your own learning experience, so pursue what interests you.

Very helpful. I will implement this physics in my game and just make some tweaks. At least I completed half part of the physics myself!

 

 

Please tell me the correct physics with which the ball should work
I would try to answer the question the other way around.

It's a game, people playing it want to have fun.

 

What is an interesting and fun way to let the ball react?

 

 

 

What about the graphics of my game? Are they looking good or the color scheme is not fitting?
It's different and interesting at least. I like it.

 

With the brown bat I have some problem with the black at the edges (top and bottom). Against the dark background, it's hard to see where the bat ends exactly. If playing with or near the edges of the bat is important, that is a disadvantage.

The green/yellow bat doesn't have that problem, the green is light enough.

 

The green/yellow bat however is not symmetrical. The yellow dot in the center is not exactly in the center of the bat vertically. If playing with the top side of the bat has a different effect then playing with the bottom side, people are going to have a hard time deciding where exactly the middle is.

The brown bat has that problem too, but less obvious.

 

I'll absolutely agree with your advice about a game being for fun. So, I'll try to keep the physics simple, fun and interesting.

 

Even thanks for the review about the game graphics, I'll make some tweaks. As for the 'center of the bat' problem, the dot was not meant to be the center (I just applied a texture to a rectangle) So, I'll make some changes about that also. Hopefully it should improve the user experience of my game!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement