Chapter 13

Ten Open-Source Game Projects

In This Chapter

arrow Checking out side-scrolling platformers

arrow Seeing sample puzzle and word games

arrow 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.

9781118235997-fg1301.tif

technicalstuff.eps Like other game samples in the SDK, this game tends to use keyboard input. If your test device is touchscreen-only, you’ll need to run the sample game in an emulator.

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.

9781118235997-fg1302.tif

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.

9781118235997-fg1303.tif

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: Open­Sudoku.

9781118235997-fg1304.tif

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.

9781118235997-fg1305.tif

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.

9781118235997-fg1306.tif

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.

9781118235997-fg1307.tif

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.

9781118235997-fg1308.tif

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.

9781118235997-fg1309.tif

tip.eps If you want to incorporate alternate input sensors such as the accelerometer into your game, this game is a good reference point.

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.

9781118235997-fg1310.tif

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset