First Program Done!

Written by  on May 12, 2014 

Hi all!

Well, I’ve made my first official real game. Don’t get too excited though, it’s just a gussied up Pong clone. The basic version wasn’t much to shake a stick at — but I’ve made some modifications to at least make it a tiny bit more exciting.

  • I’ve added the option for a second player. You can press “enter” to toggle it off or on.
  • The ball when it would spawn OR bounce off of something was set to go at a random speed. No matter what. I didn’t like how this worked at all, so I’ve changed it. I’ve lowered the maximum velocity completely, and as the match progresses the ball will get faster and faster, until a point is made. Then it resets.
  • I’ve added a PAUSE screen with instructions, in case the user needs to review them.
  • Modified the buttons for game usage. ‘W’ and ‘S’ for up and down on player 1, and just the up and down arrow keys for up and down on player two.

If I go back to this game, I kinda want to add a powerup or two that would float around lazily, back and forth. Maybe slowing your enemy, increasing your speed and/or enlarging the paddle size.

Anyway, here you go! Enjoy my first ever game.

Pong Clone!

Edit: A wise reddit user suggested that I add my source for my downloads, because who wants to download a random dude’s exe from the net? Probably a good idea.

Source Code!

Social Media Crap:

Category : BAMPGPNews

Comments

5 Responses

  1. Eric says:

    Nicely done sir. Works as expected, the extra features are nice, and it’s surprisingly well polished for a pong clone you churned out as practice. I like the music, too.

    Here’s a problem for you to solve: When the ball strikes a corner of a paddle, and the paddle is moving toward the ball, the ball ends up inside the paddle’s collision box and rapidly bounces back and forth inside the paddle until it makes its way out. Pretty much every pong clone runs into this issue (mine included, way back in the day).

    • Shaun says:

      Yeah! I noticed that too. I’m using the super mega basic form of collision detection. Let’s say you have object1 and object2 (referring to them as o1 and o2)

      basically It checks the following:

      o1’s x origin against o2’s x origin plus plus width.
      o1’s y origin against o2’s y origin plus height.
      o2’s x origin against o1’s x origin plus width.
      o2’2 y origin against o1’s y origin plus height.

      It’s rudimentary, but is quick code. I imagine later on in the series I will be introduced to more defining collision detection. It seems to be the way things go with this book.

      I do plan on adding a splash screen so you’re not thrown right into the game, and then a end game screen once the score reaches a certain threshold.

  2. Eric says:

    Yep that’s the “hello world” of collision code. Great place to start.

    The splash screen and end game screen would be a nice touch, yeah.

    • Shaun says:

      Pretty much! The next chapter fleshes things out a bit more. better collision detection, a prettier looking game loop, and I think it will be time to convert it all to Object Oriented, which will mean things will be much more modular, and I’ll feel right at home. It feels so WRONG to have everything in one code file right now.

      Also, TODO: I need to compile in Mac environments and Linux.

  3. Shaun says:

    I’ve added a super secret mode, if you can find it. Also, a splash screen.

Leave a Reply