Any good Pong articles?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
nice
Party member
Posts: 188
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Any good Pong articles?

Post by nice » Fri Jan 16, 2015 1:36 pm

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!
:awesome: Have a good day! :ultraglee:

User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Any good Pong articles?

Post by josefnpat » Fri Jan 16, 2015 8:18 pm

I once wrote PÖNG - The Well Documented Version of PONG. Perhaps this will help you out?
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push

User avatar
nice
Party member
Posts: 188
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Any good Pong articles?

Post by nice » Fri Jan 16, 2015 8:54 pm

josefnpat wrote:I once wrote PÖNG - The Well Documented Version of PONG. Perhaps this will help you out?
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?
:awesome: Have a good day! :ultraglee:

User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Any good Pong articles?

Post by josefnpat » Fri Jan 16, 2015 9:23 pm

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
Attachments
PONG.love
7d4d9370
(1.73 KiB) Downloaded 56 times
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push

User avatar
nice
Party member
Posts: 188
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Any good Pong articles?

Post by nice » Fri Jan 16, 2015 9:44 pm

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?
:awesome: Have a good day! :ultraglee:

User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Any good Pong articles?

Post by josefnpat » Fri Jan 16, 2015 10:09 pm

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:

Image
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.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push

User avatar
nice
Party member
Posts: 188
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Any good Pong articles?

Post by nice » Fri Jan 16, 2015 10:37 pm

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
paddle_direction.png (4.73 KiB) Viewed 1950 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
:awesome: Have a good day! :ultraglee:

User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Any good Pong articles?

Post by josefnpat » Sat Jan 17, 2015 3:55 am

[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
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push

User avatar
nice
Party member
Posts: 188
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Any good Pong articles?

Post by nice » Sat Jan 17, 2015 10:40 am

josefnpat wrote:
nice wrote:
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
Could you explain further what it does? personally I don't really know what's happening :P
:awesome: Have a good day! :ultraglee:

User avatar
Jeeper
Party member
Posts: 544
Joined: Tue Mar 12, 2013 7:11 pm

Re: Any good Pong articles?

Post by Jeeper » Sat Jan 17, 2015 4:54 pm

nice wrote:
josefnpat wrote:
nice wrote:
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
Could you explain further what it does? personally I don't really know what's happening :P
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.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests