GameProject: A template project for Android game development

Since my move from iPhone to Android, I’ve been getting my hands dirty with the Android SDK. Unlike the SDK for the iPhone, Google’s Android SDK allows anyone to develop applications while debugging them directly on hardware. This is the reason I never really got into development on the iPhone, as there is a marginal fee involved with being able to develop on the hardware itself. On top of that, Google has provided a plugin for the Eclipse IDE that provides an amazing experience while developing and debugging applications.

Whenever I begin development for a new platform, my interest immediately turns toward gaming. As a result, I have a template project I created that’s loosely based on the LunarLander example project provided by the Android SDK. GameProject is a project that can be imported into your existing development environment, and provides an absolute minimum of configuration that can be used to get started on a new game right away.

Download GameProject here. The steps below include things to do in Eclipse, where you can use the ‘Import…’ function on the File menu and import the entire project to your workspace. If you’re not using Eclipse, just ignore any special instructions for it.

  • /ApplicationManifest.xml: Change package name from “com.pacifiedcitizen.gameproject” to your own namespace, and the activity name from “.GameProject” to whatever your main project class will be called.
  • /res/values/strings.xml: Change ‘app_name’ value to your application name.
  • /src/com/pacifiedcitizen/gameproject/*.java: Change the package import on line 1 to match the package name you set in ApplicationManifest.xml.
  • /src/com/pacifiedcitizen/gameproject/GameProject.java: Change the import of com.pacifiedcitizen.gameproject.GameView.GameThread to reflect your new package name.
  • Rename the project folder to match what you renamed ‘GameProject’ class to.
  • After all these steps, go to ‘Project’ menu -> ‘Clean…’ and clean your project. Also, right-click the project, choose ‘Android Tools’ (might be called something else, it is near the bottom of the context menu) and choose ‘Fix Project Properties’.

After all of this, you should be able to build and run the project. You will see the results of the onDraw() function in the run() loop of the GameThread class which is set to assign random RGB values and use them to paint the entire screen. From this point, you can use the extremely helpful Android developer site to learn about SurfaceView (the class being used to manipulate the screen via Canvas), and modify the run()/doDraw() loops to do new things.

My next android post will go into the details of how this project is configured and runs. I will use my first example project, TicTacToe, to hopefully clear up any questions or issues that arise. Speaking of, if you decide to give this a whirl don’t hesitate to leave a comment with any of those questions or issues!

Cheers,
-Chris

Tags: , ,

Leave a Reply