In late 2015 and early 2016 I decided to try make a game, a classic game by the name of Pong. I’d found some online forums talking about starting out with game development in their personal lives and one piece of advice stuck with me:

Start with something small, REALLY small, like Pong. Once you’ve got that sorted make it a little bigger, say Mario Bros. and just keep building projects slightly larger one after the other. Before you know it, you’ll be making your own games.

I sat back and thought about the pieces in Pong, how small was this smallest example? You needed paddles that responded to key commands, easy enough; There needed to be a ball that could bounce off of paddles, the ceiling & floor, and that had to be destroyed and remade when it landed in a goal, so a bit more complicated; There was the need for a game manager, just to keep track of score if nothing else and if you wanted would help with a pause and exit functionality which can be simple key presses. Maybe this wouldn’t be too hard.

Let’s just pretend I was winning, okay? Making a ruthless AI is easy, making a fallible one is hard!

After a handful of hours spread over a weekend or so, I had a game. Not the most sophisticated game, not even an efficient game, but I had a game-loop that represented a classic. One thing I hadn’t accounted for at the beginning was the creation of an AI paddle, I just assumed 2 players would be playing, but that isn’t the case. At first I made the AI paddle height follow the ball height, but then the game was impossible, there may as well have been a wall there instead, it reminded me of an article I read about game AI where the writer said:

Creating an AI that can ping you across the map and get a headshot is easy, it doesn’t require much effort. Getting it to fail, and to fail in the way that a human would too? That’s really challenging.

How could I make the paddle fail? Well Pong is really all about placing the ball where you’re opponent can’t reach, so that involves the ball’s speed as well as the paddles. So I made a solution that said if the ball was outside a certain reach the paddle would go at full speed, but if it wasn’t it’d go at a lesser speed. I also made the ball increase it’s magnitude every return serve up to a limit. Again I played the game, the racket did fail now, but the movement was still quite jittery in the way that it followed the ball, because if the balls centre wasn’t inline with the paddle centre, the paddle would move. Again I went back to the AI and tweaked and turned things until the movement was cleaner, admittedly not perfect but far more smooth, I did this by saying that if the ball was outside of the paddles entire reach, not the centre point, then and only then should the AI move.

This is the majority of the script, there’s literally 5 more lines of code declaring variables.

In terms of gameplay, the game was complete, however it wasn’t a full experience. There wasn’t any sound, there wasn’t a menu system, the game didn’t even have a victory condition. The condition was easy enough, the game manager just needed to keep track of each score, which it was already doing, and then when one of them reached 5, then exit to the main menu. The sound wasn’t too hard to do either, I attached an audio source to the ball and to the game manager, the game manager one looped and became the game’s background music, the ball was set to play only when it collided with an item, paddle or wall.

I started with a basic menu, just play and exit, play would obviously lead into the game and exit would close the entire game, this required an update for the game manager so that if the escape key was pressed it’d take the player to the main menu, not just exit the game. Also to make the game more fair, the first serve was randomly determined to go left or right, and after that whoever scored last was not served to for the next round.

The menu I ended up with finally.

After the basic menu, I created another option of “control”, this was just to tell the player that the W & D keys would move the paddle, P would pause the game and Esc would bring them back to the main menu. Once that was done I thought it’d probably be best to make another small menu for the rules of the game, which basically read to keep the ball out of your goal and try to score against the opponent, first to 5 wins.

The option I’m most proud of however is the settings menu, I wanted to be able to make it much bigger than it ended up being by allowing for resolution control and input control so a player could remap keys, however without making my own input manager I wouldn’t be able to do so, and that wasn’t the focus of project, so I put it on the back-burner to return to later. However what I was able to achieve was the ability to change the volume of the music and sound effects in the game thanks to a simple pair of sliders.

A display of the volume sliders at work.

The game was, for all intents and purposes effectively done. I had a menu system that although not as vast as I had wanted was still impressive, I’d made a game-loop that was incredibly challenging but still possible to win against, and maybe it was how proud I was that I wanted to keep pushing forward with it, or maybe it was just featuritis creeping in. The game was complete but I couldn’t help but think of extra bits of polish that could be added, perhaps a “3…2…1…GO!” animation at the beginning to prepare the player, maybe the addition of an online multiplayer (something I looked heavily into and realised was very complicated and this was only meant to be a small project), and so on and so forth.

In the end however, I may not have been able to hit all the markers I came up with, and I knew parts of the code weren’t probably the most efficient method of handling problems, but I was proud. I’d taken a game, a simple game, but I’d made it mine, I gave it some small amount of character, and as my first solo-project for personal reasons and nothing else I feel like I’d won.


(UPDATE: 22/06/16)

Recently I decided in order to make some of these articles more jazzy when I finish a game, I should give you a demo! Now there are some caveats with that, right now I’m not doing any downloadable content but that will come in time, I’m undecided on giving source files or just the game. Regardless, right now I’m putting my games up on, this means that if you’d like to play my games through your browser, you’ll need to be using
A) The latest unityweb plugin
B) Firefox, Internet Explorer, Safari, Opera (you can use Chrome if you’ve certain extensions allowing certain APIs that were removed a while back I believe)

Without further a-do here is Pong!

In the event it doesn’t load, there are several simple solutions – clear your cache with CCleaner, simply reload the webpage as the game can timeout if the loading is taking too long, or just try another one of the browsers mentioned above.


3 thoughts on “So Long Pong

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s