Pong meets Breakout!

screen

Hey I made a game! Play it here

I’m really happy with how this came out. I had a simple idea and was able to work on and finish it within a week without blowing it out of proportion or anything. Many ideas I get are a simple mechanic I want to learn how to make, and once that mechanic is done I usually start on something else, so most stuff I make doesn’t get finished as a full game. Pong Out was a pretty simple idea, so it was a good project to do to actually finish something.

The basic idea is that it’s Pong, but the paddles act like the blocks from Breakout. When the ball hits the paddle, part of it disappears! Other than that, the rules are the same as Pong though, if the ball hits the left or right side of the screen the appropriate player gets a point. First to 5 points wins!

I’d like to talk about some of the development and issues that arose

Paddle Movement

This was fairly simple, the biggest issue was making a paddle whose move range/collider changed as blocks got removed from it. I ended up using a CompositeCollider2D which solved both these problems. The composite collider updates at runtime, so disabling a collider its using updates the composite collider automatically! I also ended up using rigidbodies for the paddle movement, so all the collision stuff just worked automatically as well!

Paddle/Ball Interaction

game2

This is definitely what took the longest to figure out. The idea seems simple enough, but implementing it and having it work how I wanted proved to be difficult. The final result still has some stuff I’m not entirely satisfied with, but I took the “good enough” philosophy on it so I could called it done.

I started using rigidbodies and physics for the ball and the paddles, but this gave some very common unwanted behavior. I wanted the ball the maintain a constant angle of movement, just flip it when it bounce off a wall. Using physics sometimes made it bounce in a new direction, which I didn’t want. And sometimes, for some reason, it would move with the paddle for a second then bounce off.

I went for a more scripted approach to the ball, moving the ball in its initial direction, the multiplying the move vector’s axis it by -1 when it needed to move in the opposite direction. The next biggest problem was getting it to properly hit and bounce of the paddles.

I ended up using a trigger on the ball to detect if it hit the paddle, as using OnColliderEnter2D was causing the ball to stick to the paddle for a second as the ball’s desired position moved from inside the paddle back outside it. On big problem with using triggers though was sometimes it would trigger in the paddle, move on the next fixed update frame, but still be in the paddle, so a new trigger wouldn’t be called and it would move right through the paddle instead. So sometimes the ball would just go through the paddle and the player would have no control over it.

I fixed this by moving to OnTriggerStay instead of Enter, which introduced a new problem, which I ended up preferring as a solution. With the old method only one block would be destroyed at a time, but using OnTriggerStay multiple blocks could be destroyed at once. This was a bit annoying a first, but thinking about it, it kind of solve a balance problem. If only one block gets destroyed at a time, the the player who loses the first block would always be at a disadvantage. But, by having multiple blocks destroyed at once, it helps remove that advantage as one player could lose more blocks than the other at any given time.

It’s still not a perfect solution, and I might go back and try to find something better, but for the time being it’s good enough.

Juice!

game1

I knew just a simple pong game with breakout paddles wouldn’t be very eye-catching by itself. People might be interested, but would probably stop after a short while once they “got it.” To mitigate this, I wanted to try and “juice” up my game. Adding fun little effects and ways for game objects interact to make it feel like more is happening than it actually is. This process probably took about half the time of the game and was something I hadn’t done on a “finished” level before, so it was good experience.

I think the first way I added some juice was through the menus. Fun little animations and transitions add more visual interest than UI just popping in and out as they’re turned on or off. On animation I particularly enjoy is the transition from the “Player X Wins” screen back to the main menu. I wanted to make it look like the text kinda broke from it’s holder as it fell off screen. After I finished the animation I added the button to actually take you back to the main menu. Trying to figure out what an interesting way to move it off screen would be, I noticed the text overlapped it when it fell, so I thought it’d be fun if it just sorta smacks it off screen with it. It looks a bit janky, but I think it adds to the fun of it.

Audio is a huge part of “juicing” stuff, it’s surprising how much just a little bit of sound can add to the engagement of a game. Just adding the “pong” sounds when the ball bounced on the walls made it feel so much more like a game than some half-baked prototype. Another thing I wanted to do from the start was have an old synthesized voice narrate parts of the game, like the title screen or who won. There’s also a little easter egg where the voice says “ping-pong” as the ball bounces off the paddles, which is fun.

Another big area was the ball and paddles, making them feel more interactive. The ball, for example, gets a little bigger than shrinks down when it bounces off something. This was accomplished with a simple animation. The ball also has a short trail and makes some particles when it explode. The blocks on the paddles fall and fade away when they’ve been hit by the ball.

Further Ideas

I had a few other ideas I wanted to add, mostly gamemode stuff. Some different win condition stuff, a singleplayer mode where you keep your paddle alive for as long as possible, a mode where paddles don’t regenerate, or one where the player who scored a point’s paddle doesn’t regenerate. At the end of all this I also got the idea of the paddles were on joints and started to spin as the ball hit them, that might be a fun idea some day.

Tags:

Categories:

Updated: