First Game : Planet Ball

Hi folks: I’ve been lurking here for a while, watching, learning.

Before I start working on my cool game idea I decided to take some often given, but rarely taken advice. I built a simple game to learn a bunch of the basics. I bought “Killer Game Programming in Java” and then read some post here on how to improve the code examples in that book (such as fixing his double buffering code to use BufferStrategy instead of creating a 2nd buffered image for every frame.).

So I built PlanetBall. The inspiration for PlanetBall was “What if you were playing Pong, but instead of the paddle, you were the ball?”

PlanetBall is a 2 player game where both users use the same keyboard to move their planets around in space. One player uses ASDW to move and B to brake. The other player uses the arrow keys and Number Pad 0 to brake.

If you capture a planetoid of your own color you gain 10 points.
Capture the wrong color you lose 5 points.

Bump the other player and you both lose 2 points.

Capturing your own color asteroid gives you 25 points
Capturing the wrong color loses 15 points

If you get sucked into a black hole the nicest thing which will happen to you is you lose 20 points.

I have 4 levels of increasing difficulty. I was able to use OpenAL to get the sounds working and overall, I think it’s a playable game.

Right now I have a bug which happens when you choose to go back to the main menu and then you play levels which have already been played. For some reason a hashmap I created is going to null. Once that’s fixed I’ll give you a download link if you’d like to try it.

It looks like I fixed the bug so it’s available as a zip file at http://www.brouelette.com/downloads/

It’s a large file of nearly 130 megs. The majority of it is the music wave files. I’ll have to look into reducing file sizes for my sound files.
Note: I’ve removed some of the extra music and reused the same music for all the scenes. It’s down to 23 megs now.

I hope you enjoy it.

It runs and has nice music.

This is one big download! I’ll try it if I ever get the whole thing downloaded in one HTTP session.

124MB, downloading a 500KBps!! :o

Give me a sec…

Runs really well and it was quite fun! I got my brother to play and I beat him ;D

Great job :slight_smile:

Oh no, it’s too big for me! :o

This was very much a learning experience/proof of concept project.

The vast majority of that file size is the wave files for the music. I’m using OpenAL and at this point I only know how to use their WaveFile class to load sound data. I’m researching if it’s possible to switch to mp3 files. Beyond that I could see if I can:

Reduce the sound resolution in Audacity to get smaller files
Reuse the sound files and have only 2 music themes instead of 3.
Shorten the loop length.

I’d love to get it well under 100 megs.

I have to say, I learned a ton writing this. I had a good time building my own little 2D game engine. Just in this simple project I had to learn:

  • Game loop timing
  • Double Buffering
  • Key Event binding
  • The update/render/paint loop
  • Collision detection
  • Inelastic collision (billiard ball physics)
  • Gravity simulation
  • Sound programming
  • Scene management
  • Timer events
  • Basic animation (watch what happens if you touch a black hole)

I’ve worked on web based software for pretty large companies for the past 20 years and this was a completely different sort of code. For one thing, it was fun to work on. It’s nice to have fun writing code again.

BTW, F4 is my debug key. It shows all the collision rectangles as well as the FPS, Max FPS, Game time (to test timer events) and scene name.

I reeeaaally think your top priority right now should be using mp3/ogg instead of wave. Downloading more than 100MB for a Indie game, is for me (and a lot of people I guess) a show stopper.

I think you’re right. I just found a tutorial on using Ogg Vorbis with OpenAL in Java. I think doing that conversion will be this week’s project.

Hey Guys, I removed the extra music files and just reused the same music for each scene. It’s down to 23 megs now.