We are often asked “how did you learn to code?”, and for tips about how to get started with game programming. I learned most of my programming from books and from hacking around in the few examples I could find (there was no Internet back then). Our Mojam “Catacomb Snatch” source code could possibly be a good starting point for new programmers, so here’s a quick getting-started guide!
First of all, there are some prerequisites. You will need the following:
- A Java development kit installation. Get it from Oracle
- The Eclipse IDE (you can use other IDEs, of course, but in this guide I’ll be using Eclipse)
- The Catacomb Snatch source code from your Humble Bundle
After installing the JDK and placing Eclipse somewhere, start Eclipse and create a workspace (such as “C:\workspace”). Then create a folder in that workspace called “mojam” (such as “C:\workspace\mojam”) and place the contents of the source zip in that folder. It should look something like this:
Then switch to Java perspective in Eclipse and right-click in the “Package Explorer” and choose “New->Java Project,” like this:
In the popup dialog, enter the same name for the project as you called the folder in your workspace. In my case it was “mojam”:
Eclipse should be able to locate source and library folders automatically, so the next step is to try to start the game, like this:
Now you will notice that the game instantly crashes! Oh my… but don’t worry, it can be fixed! Go to “Run->Debug Configurations…” and find the “MojamComponent” configuration. Select “Classpath” and “User Entries”. Click on “Advanced” and select ““Add Folders.” Locate the folder called “res” and add it. Now the game should run when you press “Debug”!
Now you can play around with the source code!
- Fix the Harvester crash bug. The reason it crashes is that it’s trying to use the synchronized random during the render step (will cause de-synchronization in multiplayer!). Try to fix this (and synchedRandom should still be null during rendering) :)
- Fix the players receiving the other player’s score.
- Make multiplayer more smooth in high-latency situations. Hint: Increase “currentTurnLength” in TurnSynchronizer.java. (I incorrectly wrote “currentTurnTickCount” before, because of brain fart.)
- Multiplayer for more than 2 people (will require a lot of changes, especially to the way the server socket is treated)
- Change the game in to a tower defence ;)
- Try the game with WASD+Mouse controls
- … or something else
UPDATE: Some people have problems with missing “PaulsCode” libraries. It seems like Eclipse sometimes doesn’t add the JAR files in the “lib” folder to the class path, so you must do that manually. To do that, right-click on the project and select “Configure Build Path,” and then add the JARs to your class path.
UPDATE 2: If you want to continue exploring game development in Java, you can find more resources and beginner’s help at https://www.java-gaming.org/