Page 1 of 2
Any good Pong articles?
Posted: Fri Jan 16, 2015 1:36 pm
by nice
Hello boys and girls!
I'm wondering if anyone of you know any good articles that has a focus on Pong.
What I want to see is something that talks about the paddle mechanics and the balls (heh) behaviour.
Thanks!
Re: Any good Pong articles?
Posted: Fri Jan 16, 2015 8:18 pm
by josefnpat
I once wrote
PÖNG - The Well Documented Version of PONG. Perhaps this will help you out?
Re: Any good Pong articles?
Posted: Fri Jan 16, 2015 8:54 pm
by nice
Oh nice!
What I would like to see is some form of documentation on why Pong works as it does, your coded example is really sweet but to me it doesn't really explain
why some certain parts of your code does what it does.
If you could be so nice, can you add a .löve file so I could take a look at how the game plays?
Re: Any good Pong articles?
Posted: Fri Jan 16, 2015 9:23 pm
by josefnpat
nice wrote:What I would like to see is some form of documentation on why Pong works as it does, your coded example is really sweet but to me it doesn't really explain why some certain parts of your code does what it does.
What parts can I extrapolate on? I am more than happy to expand the in-line documentation :)
Attached is the code in the gist packaged in a .love
Re: Any good Pong articles?
Posted: Fri Jan 16, 2015 9:44 pm
by nice
josefnpat wrote:What parts can I extrapolate on? I am more than happy to expand the in-line documentation
The thing is that I want to replicate Pong and I want it to as close as possible to the original as possible and with that I can use it as a base for future projects.
But what I'm curious about right now is the behaviour of the paddle and maybe the ball, how many directions does the paddle have? is the paddle divided up in parts?
Is there a standard for the speed of the ball? does it have direction values too?
Re: Any good Pong articles?
Posted: Fri Jan 16, 2015 10:09 pm
by josefnpat
nice wrote:The thing is that I want to replicate Pong and I want it to as close as possible to the original as possible and with that I can use it as a base for future projects.
A 1:1 copy of Pong may prove to be very difficult, but an interesting goal nonetheless. There are many many versions of pong, and you will want to decide on which one you want to emulate. I believe the initial pong was created by Allan Alcorn as a training exercise, so it is all done in hardware.
Here is an image of the schematic that may provide you with more information:
nice wrote:how many directions does the paddle have?
https://gist.github.com/josefnpat/a1abc ... in-lua-L64
Two directions. "Up" and "Down"
nice wrote: is the paddle divided up in parts?
https://gist.github.com/josefnpat/a1abc ... in-lua-L14
No, the paddle has a x,y,w and h. from that a collision can be determined:
https://gist.github.com/josefnpat/a1abc ... in-lua-L31
nice wrote:Is there a standard for the speed of the ball?
The speed is defined here:
https://gist.github.com/josefnpat/a1abc ... in-lua-L22
For whatever you consider the "original" version of pong, I do not know. You would have to research that.
nice wrote:does it have direction values too?
The direction is swapped between the players.
https://gist.github.com/josefnpat/a1abc ... in-lua-L28
I believe that is how the original version did it.
Re: Any good Pong articles?
Posted: Fri Jan 16, 2015 10:37 pm
by nice
josefnpat wrote:
nice wrote:how many directions does the paddle have?
Oh god, that's a lot of stuff..
By directions I meant how many ways can the paddle bounce back the ball like this:
- paddle_direction.png (4.73 KiB) Viewed 5033 times
And as you said, making a game that's as close to the original would be difficult but I want to make as close as possible.
Sorry if I wasn't clear enough I'm a bit tired while typing this
Re: Any good Pong articles?
Posted: Sat Jan 17, 2015 3:55 am
by josefnpat
[quote="nice"]
paddle_direction.png
/quote]
Now I understand!
The vy (vertical velocity of the ball) is calculated by the percentage offset away from the center of the paddle.
https://gist.github.com/josefnpat/a1abc ... in-lua-L36
Re: Any good Pong articles?
Posted: Sat Jan 17, 2015 10:40 am
by nice
Could you explain further what it does? personally I don't really know what's happening
Re: Any good Pong articles?
Posted: Sat Jan 17, 2015 4:54 pm
by Jeeper
nice wrote:
Could you explain further what it does? personally I don't really know what's happening
The variable vy (Vertical Velocity in this case) determines the vertical direction of the ball. When the ball collides with the paddle it checks where on the paddle it has collided; the higher up the collision was the lower it sets the velocity, the lower the collision was the higher it sets the velocity.