Figure 13-1: Lunar Lander.
Chapter 13
Ten Open-Source Game Projects
In This Chapter
Checking out side-scrolling platformers
Seeing sample puzzle and word games
Researching physics-based games and 3D
Often the best way to get where you’re going, especially when developing games, is to build on what others have done already. Even if you do start completely from scratch, looking at how someone else already accomplished something similar can speed up your development time or give you new ideas and insights.
The following ten Android game projects are all open-source. That means the source code and all resources for the game are made freely available. Be sure to check the license for each, though. Just because they’re free of charge doesn’t mean that you can simply copy and paste their code over into your game.
I’ve included a good cross-section of genres and approaches, so if the two games built in this book weren’t the kinds of games you necessarily want to build, chances are that at least one of these free projects fills that bill.
Lunar Lander
The Android SDK comes bundled with example projects that exemplify best practices with regard to developing certain types of apps. One of the earliest examples of this is the Lunar Lander game, shown in Figure 13-1. The project is organized very similarly to our Whack-a-Mole game and uses SurfaceView. If you’re interested in building a 2D simulation game with real-time controls, you should definitely check this example out.
Figure 13-1: Lunar Lander.
To load an existing sample from the Android SDK, follow these steps:
1. In Eclipse, right-click the project explorer and select Import.
2. Select Existing Android Code Into Workspace and then click Next.
3. Browse to the directory in which you installed the Android SDK.
Samples are located in /samples/<android-sdk-version>
. You probably want to use samples from the latest version.
4. Click Finish.
If your project includes errors at this point, make sure your build target is the same as the SDK version the sample is from:
1. Right-click the imported project and select Properties.
2. Select Android from the left menu.
3. Check the box associated with the build version that matches the sample directory of the project.
Replica Island
We didn’t cover how to implement a side-scrolling platformer. If you’re interested in implementing this type of game, you’ll definitely want to check out Replica Island, shown in Figure 13-2. The game stars the Android robot himself, navigating maze-like environments filled with obstacles and items to gather. The game was developed by Chris Pruett when he worked for Google, and became a popular free game in the market.
Figure 13-2: Replica Island.
The source and all related project files are here:
http://code.google.com/p/replicaisland
.
Alien Blood Bath
This game isn’t nearly as cute and family-friendly as Replica Island, although it follows in the same side-scrolling platformer genre. Alien Blood Bath (shown in Figure 13-3) is a rewrite of the Windows game of the same name.
Figure 13-3: Alien Blood Bath.
Probably not hard to figure out what the theme and the game play are like on this one!
The project files are available here:
http://code.google.com/p/alienbloodbath
OpenSudoku
If bathing in the blood of aliens isn’t your thing — but brain-bending puzzles are — then check out OpenSudoku, an open-source version of the popular grid-and-numbers game. (See Figure 13-4.) It features 90 puzzles with three difficulty levels.
Google Play has lots of existing Sudoku games, but working through this code and implementing your own puzzles and variations will definitely be useful if you want to build games in this genre.
The project files are available here:
http://code.google.com/p/opensudoku-android
Figure 13-4: OpenSudoku.
Lexic
Lexic (see Figure 13-5) is a word game in which the player is given three minutes to find as many words as possible on a grid of randomized letters (another popular subgenre of word games).
Figure 13-5: Lexic.
The code isn’t very well commented, but it’s still a useful starting place if you want to build a word game.
The source code is here:
http://code.google.com/p/lexic
Newton’s Cradle
Newton’s Cradle is the popular desk toy — metal balls suspended from strings knocking into one another — brought to life on Android. (See Figure 13-6.)This is a great (and simple) place to start looking into the workings of a simple physics-based game.
Figure 13-6: Newton’s Cradle.
The source is here:
http://code.google.com/p/newtonscradle
Vector Pinball
With purposefully simple graphics, Vector Pinball gives you an efficient primer on how to translate arcade classics into cool mobile games. (See Figure 13-7.) Vector Pinball actually uses a wrapper around the Box2D physics engine, so it’s a reliable resource for building games with physics.
The source is here:
https://github.com/dozingcat/Vector-Pinball
Figure 13-7: Vector Pinball.
asqare
Match-3 games make up an incredibly popular genre of casual games: The player moves simple elements in a grid until three or more of the same kind are in a row. I have a couple of games that fall into this class or are mashups of other games that use this concept. Some of the most popular casual games of all time are match-3. Asqare (don’t know where they got that spelling) does a great job of showing how to implement this type of game, with simply-colored sprites. (See Figure 13-8.) Use it as a basis for inspiration for your own themed match-3 game, and you just might have a hit on your hands!
The source is here: http://code.google.com/p/asqare/
.
Figure 13-8: asqare.
tiltmazes
Almost everyone has a wooden labyrinth game sitting around in the attic or the garage: The player uses knobs to tilt the game surface, trying to navigate a metal ball through the maze. (See Figure 13-9.) This open-source version uses the accelerometer to allow the player to tilt the device to roll the virtual ball around to collect tokens.
Figure 13-9: tiltmazes.
The source code is here:
http://code.google.com/p/tiltmazes
GL ES Quake
We didn’t cover 3D game development in this book, but if you’re feeling adventurous, this version of the popular id Software game Quake, ported to the Android platform, might be the place to look. (See Figure 13-10.)
OpenGL ES (for Embedded Systems) is a scaled-down version of the OpenGL 3D graphics API and is the supported standard for Android. It’s a big leap from 2D to 3D, and the complexity and demands of the hardware increase quite a bit. But mobile devices do keep getting more and more powerful, so if this is the direction you want to go, dive right in.
The source code is here:
http://code.google.com/p/glesquake
Figure 13-10: Quake.