Can we make Pong in less than a 100 lines of Javascript?

The original Pong took Atari over 3 months to complete back in 1972. The classic arcade game was one of the first commercially successful games that paved the way for the game development industry. Additionally, it’s simplicity makes it one of the first projects that any programmer takes on. As a showcase of how much easier programming has become in the past 50 years, we’re going to be attempting to make Pong in less than 100 lines of Javascript! You can play the finished project deployed o

December 23, 2021 2 Min Read
Can we make Pong in less than a 100 lines of Javascript?
Can we make Pong in less than a 100 lines of Javascript?

Codesphere

From everyone in the Codesphere Team:)

Table of Contents

The original Pong took Atari over 3 months to complete back in 1972. The classic arcade game was one of the first commercially successful games that paved the way for the game development industry.

Additionally, it’s simplicity makes it one of the first projects that any programmer takes on.


As a showcase of how much easier programming has become in the past 50 years, we’re going to be attempting to make Pong in less than 100 lines of Javascript!

You can play the finished project deployed on Codesphere here.

Let’s get started!


Our Different Components

There’s going to be four parts that we need to build for our pong game:

  1. Graphics
  2. Paddle Movement
  3. Bouncing Ball
  4. Score Keeping

Graphics

I’m going to cheat a little bit and use a graphics library to save us some menial work so we can strictly focus on the game logic.


Paddle Movement

Next up, let’s create two paddles and draw them onto the screen. Additionally, let’s allow the player to move them (I’ll use the built in keyDown function from P5.JS)


Bouncing Ball

Now let’s add in a ball. When the ball hits the top or bottom border, we want it’s y velocity to switch directions.

When the ball hits one of the paddles, we want it’s x velocity to switch direction and increase slightly(To hit harder). Additionally, to make the game more fun we’ll randomize the y velocity so it is harder to anticipate the ball.


Score Keeping

Finally, let’s start tracking the score. When the ball hits the left or right border we’ll change the score and reset the position of the ball. We’ll then display the score at the top of the screen!


And there you have it! We’ve created Pong in less than 100 lines of code!



If you’re looking to show off a game you make, the easiest place to deploy it is Codesphere. Codesphere is the only cloud provider that makes cloud deployment as easy as local deployment!

Happy Coding and Merry Christmas!

About the Author

Can we make Pong in less than a 100 lines of Javascript?

Codesphere

From everyone in the Codesphere Team:)

We are building the next generation of Cloud, combining Infrastructure and IDE in one place, enabling a seamless DevEx and eliminating the need for DevOps specialists.

More Posts

Changelog LTS Version Q3 25

Changelog LTS Version Q3 25

New cli, restricted domains, improved git integration, frontend improvements and more in the latest LTS version.

From Dev Chaos to Cloud Clarity: No More “It Works on My Machine”

From Dev Chaos to Cloud Clarity: No More “It Works on My Machine”

Tired of the “It works on my machine” nightmare? This blog explores how Codesphere eliminates environment drift by letting you develop in production-grade cloud workspaces. so your code runs the same everywhere, from dev to deploy. Build smarter, ship with confidence.

From Friction to Flow — How Codesphere Transforms Productivity

From Friction to Flow — How Codesphere Transforms Productivity

Discover how Codesphere transforms software development by unifying coding, CI/CD, deployment, and infrastructure into one seamless platform. Boost developer productivity, reduce DevOps overhead, and go from idea to live without switching tools or breaking flow.