Game Development Reference
In-Depth Information
Chapter 5
An Android Game
Development Framework
As you may have noticed, we've been through four chapters without writing a single line of game
code. The reason we've put you through all of this boring theory and asked you to implement
test programs is simple: if you want to write games, you have to know exactly what's going on.
You can't just copy and paste code together from all over the Web and hope that it will form the
next first-person shooter hit. By now, you should have a firm grasp on how to design a simple
game from the ground up, how to structure a nice API for 2D game development, and which
Android APIs will provide the functionality you need to implement your ideas.
To make Mr. Nom a reality, we have to do two things: implement the game framework interfaces
and classes we designed in Chapter 3 and, based on that, code up Mr. Nom's game mechanics.
Let's start with the game framework by merging what we designed in Chapter 3 with what we
discussed in Chapter 4. Ninety percent of the code should be familiar to you already, since we
covered most of it in the test programs in the previous chapter.
Plan of Attack
In Chapter 3, we laid out a minimal design for a game framework that abstracts away all the
platform specifics so that we could concentrate on what we are here for: game development.
Now, we'll implement all these interfaces and abstract classes in a bottom-up fashion, from
easiest to hardest. The interfaces from Chapter 3 are located in the package com.badlogic.
androidgames.framework . We'll put the implementation from this chapter in the package,
com.badlogic.androidgames.framework.impl , and indicate that it holds the actual implementation
of the framework for Android. We'll prefix all our interface implementations with Android so that
we can distinguish them from the interfaces. Let's start off with the easiest part, file I/O.
The code for this chapter and the next will be merged into a single Eclipse project. For now, you
can just create a new Android project in Eclipse following the steps in Chapter 4. At this point, it
doesn't matter what you name your default activity.
193
 
Search WWH ::




Custom Search