Pong project - home

As my first project, I have chosen the classic Pong. It ticks all the boxes: it’s very simple in terms of graphics and mechanics, and its gameplay is known to virtually everyone. It will be a great hello world-type project.

In a series of upcoming posts I will describe how to implement it and also delve into topics such as the choice of nodes, code extensibility, and other aspects, rather than just presenting and explaining the code.

This post will be updated as I create new content for this project.

Go to post list

Project repository

You can access the current state of the Pong project at https://github.com/marcinsendyka/pong. This is runnable project, with features list growing over time. tutorial/ directory contains some example scenes to play around with different nodes, settings and code.

Breaking down Pong

Let’s break the game into smaller pieces. Even if it’s just Pong, I think this is a good exercise to do. This will be mostly based on what I remember from playing the game in the ’90s and on what I’ve seen in recent implementations and on the Wikipedia page.

When questions arise during implementation, I can always come back here and let this breakdown guide me.

Mechanics

Mechanics are dead simple:

  • There is a ball - made up of only a few pixels, to be exact.
  • There are two paddles. Since this is a two-player game, each paddle has its own set of controls.
  • Ball bounce of a paddle when it collides with it.
  • When ball goes off screen horizontally, it means that the player on the opposite site of the screen scores a goal and receives 1 point.
  • Ball cannot go off screen vertically; it bounces off the top and bottom of the playing field.
  • The score is displayed on the screen.

That’s it. Once I have those basics covered, maybe I’ll consider some improvements here and there, or even add my own twist to it, but this is the minimum plan that I want to achieve.

Visuals

Well, the visuals are also very basic, but hey, that’s why I picked Pong! Game screen will display the following:

  • Ball - simple sprite is enough.
  • Paddle - no sprite is needed; a ColorRect node will suffice.
  • Playing field - again, a ColorRect node will do.
  • Score - simple text label displaying score.

Classic Pong had a very low resolution, with clearly visible pixels and ‘choppy’ movement. I’ll try to reproduce that retro style.

Sentiment

The gameplay is very fast. Given the high speed of the ball and the small size of the paddles, it’s easy to score a goal. The score is clearly displayed on the top of the playing field, and a sound is played when a goal is scored. All of the above is meant to provide a competitive atmosphere.

Post list

Resources