Code Pong in 10 Minutes
- Jack
- Aug 14, 2017
- 1 min read
Hi everyone, so here is the first video I've made and the first game I've made as well. I have taken some courses on the basics of JavaScript and how to make objects move, but this the first complete game I've made for the browser!
And as a challenge it went well, I had to rerecord the video a few times because of errors on my part! Not pressing play being one!! But here it is my first proper attempt at coding, and its a working game in less than 75 lines of code!
For anyone who's wanted to do this but not known where to start, Pong is definitely the best place. The mechanics of the game are simple enough to be worked out and their are only three objects to be concerned about: the ball and two paddles.

The function to make the ball move across the screen is shown above. As you can see the logic behind it is easy to understand. if the ball hits the top (0) or the bottom of the canvas (height) reverse the speed in y by multiplying by -1. If the ball goes off the left or right edges, without touching the paddle, call a reset function and add a point to the appropriate player's score.
In future videos and blog posts I will go through declaring variables, if statements, loops, etc, and make this into a follow along video series. However, for now please just enjoy the video and let me know what you'd like to see me code next!
Comments