- The Mobile Game Market
- The World of Computer Games
- AndEngine Examples
- Summary
- Exercises
The World of Computer Games
People have been playing games on computers for almost as long as electronic computers have existed, and a rich variety of games has been invented. In her book Reality Is Broken, Jane McGonigal says that most games have four attributes:
- A goal: Games clearly define a goal for the players to achieve. It's important that the goals be challenging, yet achievable. Ideally, players are always playing at the leading edge of their ability. Goals give the players a sense of purpose in playing the game.
- Rules: Games have rules that all the players agree to follow. The rules often make achievement of the goal difficult, which in turn encourages players to be creative.
- Feedback: A game has to tell the players how they are doing. Indeed, an interesting, creative feedback system is key to making a game enjoyable.
- Voluntary participation: It just isn't a game unless you really want to play. This aspect of games implies the players' acceptance of the goal, rules, and feedback system.
Before we create a new game, we want to think about which types of games exist, as well as which types work well on mobile devices and which don't. We also want to take a look at the components that are common to all computer games.
Game Genres
Game developers didn't start out categorizing their games, and there is no standard list of categories. Nevertheless, over time games have been grouped into classes by different people in different ways. The categories identified in this section are not meant to be canonical, and they admittedly overlap in a number of areas. The exact categorization really isn't important—the point is that numerous types of games can be developed.
Skill or Action Games
Action game players typically have to use some real-time skill (e.g., jump a barrel at the right time, shoot at a moving target) to be successful. Subtypes with some examples include the following:
- Maze games
- Platform games where the player moves platforms around either to get somewhere or to stop adversaries
- Tower defense games: the player defends something (the tower) from an oncoming horde of bad guys
- Shooters: with the playing field either fixed, sliding, or scrolling
- One-on-one fighting games: where two opponents battle it out
- One-to-many fighting games: where the player fights through a gang of opponents (often martial arts related)
- First-person shooters (FPS): where the player's view is that of the shooter
- Third-person shooters: same as FPS, but the point of view is that of a third person
Strategy Games
Strategy games are less about reacting to real-time events, and more about devising and implementing a strategic plan to overcome obstacles. They include the following types of games:
- Turn-based games: including traditional board games
- Timed strategy games: where each move occurs in a fixed time
- Massively multiplayer online role-playing games (MMORPs): an extension of the old Dungeons and Dragons genre, in which players assume roles and play against others online
Adventure or Storytelling Games
Adventure and storytelling games are built around a rich storyline, with well-developed characters and a story that defines the player's purpose in playing the game.
- Simpler 2D story games often involve mazes and interactions with other game entities.
- Complex 3D story games can show different points of view as the game is played and the story spun. Some have been turned into Hollywood movies.
Simulation Games
Typically, simulation games depict some real situation, such as a vehicle that the player can operate. The games reproduce the physics of the real situation and can be good enough to use for instruction as well as for just playing a game. They include the following types of games:
- Sports simulators
- Flight or space simulators
- Driving or racing simulators
- Boat or submarine simulators
- Life simulators (overlap with strategy games)
Puzzle Games
Many puzzle games are direct translations of printed puzzles (e.g., crosswords), but the genre also includes matching and hidden object games. Complex games often include smaller puzzle games to solve as part of the larger game. Examples of puzzle games include those based on the following concepts:
- Word based (e.g., crosswords)
- Number/math based (e.g., Sudoku)
- Visual matching
- Hidden object (e.g., Minesweeper)
- Construction from a set of pieces
Augmented-Reality Games
It's fine to play games just for the fun of it, but sometimes there's a bigger motive. As Jane McGonigal's Reality Is Broken points out, some games are intended to augment reality in such a way that our real lives are made easier. Examples of augmented-reality games (ARGs) include the following games:
- Jetset: a game that simulates the security line at an airport (to help you pass the time while you wait in the real line)
- Chore Wars: a game that turns household chores into creative competition
- World Without Oil: a game that encourages energy conservation by simulating a world where oil products are in very short supply
Games for Mobile Phones
With this rich variety of game types to choose from, we need to focus on those that are most appropriate for mobile platforms such as phones and tablets. We also need to focus on those games whose development by a small group of people is feasible.
Given the potential size of the mobile device games market, it's not surprising that a substantial amount of research and thought have been put into what makes a good mobile game. The usual principles of good computer game design still apply, along with special characteristics of good mobile games:
- Don't waste the player's time.
- Provide help on playing the game.
- Make the game goals easy to understand.
- Show game status clearly.
- Mobile users typically play games in short sessions.
- Players need to easily pause and resume a game, and the phone should be able to pause and resume games when necessary (e.g., for an incoming call).
- Players should be able to make game progress in a short period of time.
Mobile devices have physical constraints that affect games:
- Small screen size and a variety of screen sizes, resolutions, and pixel densities
- Variety of user input methods (e.g., one- and two-handed operation, touch, keypad, multi-touch, keyboard, Dpad, trackball)
- Limited computational power
- Limited battery (a factor that limits power-intensive graphics and computing)
Even if you had the development resources to create a really snazzy 3D first-person shooter game like Halo, players are unlikely to sit with their smartphone and play it for hours the way they might with the XBox version. Users are much more likely to play mobile games in short sessions, pausing and resuming the game perhaps days later.
Speaking of resources, what does it take to create a commercial game? A typical console game for a single console can easily take $10 million to develop, and two or three times that amount for multiple-console development (it has been estimated that some complex games cost as much as $100 million to create). The software development kit (SDK) and license to create a console game alone can cost thousands of dollars. If you think about what goes into a professional 3D console game, it's easy to see where the costs mount up—3D artwork, motion capture, animation, game play, user testing, and software development are all both time consuming and expensive.
This book is about you and maybe one or two friends creating your own mobile game for the Android platform. The Android SDK is free, and as of this writing, it costs only $25 to sign up for Android Market and sell your game to anyone with an Android device. We'll stick to 2D (two-dimensional) games, which makes the artwork and the programming simpler. As you'll see, the basic game structure and components of any 2D game are pretty much the same no matter what the genre, but we need to pick one as an example.
Components of a Typical Game
Before we look at the specifics of the example game, let's examine the general components that we need to work into the game and implement in the code. Here are some components that will be part of our game.
Opening (Splash) Screen
To maximize performance as the game is being played, the graphics needed for a game level are often loaded before the level is started. During the loading process, which can take several seconds, you don't want to leave the user with a blank screen, so you display a splash screen. It lets the user know that the game is working as it should. Splash screens are optional, but we'll include one in our game, just to show how it's done.
Menu Screen
Once the game is ready to run, we'll need a place for the user to enter various options (e.g., turn the sound on/off, get help in playing the game). This is typically done with a graphical menu screen that presents the options and either implements the option or calls another screen (such as Help) to do so.
Music
For most of us, music has strong emotional influence. Background music is very important for setting the mood of your game, and helping with the transitions between parts of the game.
Sound Effects
Sound effects can make a game a lot more fun. When two objects collide, players expect to hear a sound of some kind—whether it's a clang, a thud, or a boing. Our example game also incorporates sound effects for each of the game characters. Each villain has a characteristic sound effect accompanying his or her presence in a scene.
Time
Most games will incorporate time—either clock time (scoring completion of a puzzle based on the time taken to solve the puzzle) or playing against moves the computer (or computer-driven adversaries) makes in real time. In our game Virgins Versus Vampires (V3), this factor takes the form of killing the villains before they can reach the virgins.
Lives
Games have to be challenging to be fun, so the player has to fail every once in a while. Killing the player off (in a virtual way) is a convenient way to give failure a consequence. Some games give the player multiple lives per session, whereas others (and V3) give the player only one life.
Obstacles
Obstacles are used in different ways in different games. In many games, the player is trying to achieve some goal, and obstacles are thrown in the player's path. In tower defense games (and V3), it's the adversaries who are trying to reach a goal, so the player throws obstacles in their paths.
Levels
Challenging games are fun, but it's important to provide a range of challenges, so that players can start with easy challenges and gradually ramp up to higher challenges as their game-playing skills and experience improve. Levels are a proven way to achieve this effect—the player learns how to play the game in the first few levels, and his or her skills have to continue to improve as new levels are presented. This is also a great way to add some variety to the game.
Adversaries
The adversaries in a game are sometimes referred to as entities (although AndEngine uses that word to mean something else). These characters are the villains (or other players) that the player must overcome to win. They are distinct from obstacles in that they take action against the player—obstacles are more passive. We've listed the entities for V3 later in this chapter, along with an outline of their behavior.
Player
Of course, the player is the most important component of any game. The whole point is to keep the player engaged and interested so he or she will keep playing the game. The player has to be challenged by the game, but not too challenged to give up in frustration. The game has to include enough variety to maintain the player's interest, and rewards have to be doled out to recognize success in playing the game.
Scenes
If you think of the game as something like a movie, each screen that is displayed to the player is something like a movie scene. Each scene has background graphics that don't change much (although the player's point of view might change). Animated graphics are then added to the scene to implement the entities and obstacles that interact to make the game.
Virgins Versus Vampires
A popular genre on mobile devices is the tower defense. These games are fairly simple to understand (stop the bad guys), they lend themselves to interrupted playing (pause/resume), they fit well on a small screen, and they don't require a lot of computer horsepower. On the production side, the artwork for a tower defense game is relatively simple, and it makes good use of the major elements of computer game programming. We also want the game to be fun to play, of course, so we'll try to inject some humor and challenge into the genre.
We need a "tower" to protect. Offhand, I can't think of anything that's been protected more vigilantly over the course of history than virginity, so we'll make that the target of the bad guys. Vampires are the trendy bad guys these days, so we'll incorporate them as well. Maybe we can even find a way to fit in the theme of the "vampire with a heart of gold"—ambivalence always adds interest.
Figure 1.1 shows what the screen will look like during a session of our game, which we'll call Virgins Versus Vampires.
Figure 1.1 Screenshot of Virgins Versus Vampires game
The V3 game is available for free on Android Market. Take a few minutes right now to download it to an Android device and play with it for awhile. At least finish Level 1 of the game, which you should do fairly quickly, to get an idea of the flavor of the game.
We need a variety of obstacles that we can use to impede the vampires' progress. We'll use the items described next for this purpose.
Bullets
We'll have a bullet weapon that players can fire by placing it on the playing field and letting it go:
- Kills: anything it hits
- Life: from where it is launched until it goes off the screen
- Scoring: not so high (per vampire), because it's easy to kill a whole line of vampires
Hatchets
The hatchet weapon is also placed by the player and thrown when they let go of it:
- Kills: the first vampire it hits
- Life: from launch until it hits the first vampire
- Scoring: higher, as it kills only one vampire
Crucifix
The crucifix just stays where the player puts it, and waits for a vampire to trip over it.
- Kills: the first vampire who runs into it
- Life: from placement until it kills a vampire
- Scoring: highest, as it depends on a vampire stumbling into it
The virgins will be held in Miss B's Girls' School on the left of the screen, with bad guys coming from the right. The game player's task is to throw obstacles in the way of the marauding bad guys to keep them from reaching the castle. We need to give the player a way of earning obstacles, placing obstacles, and watching the progress of the bad guys. We want multiple levels, so players can start off with easy games and progress as their strategies and talents improve. And, of course, we want to be able to assign scores and track them.
Design of V3
Once you have a game concept outlined, the next step in designing a game is to envision the scenes needed and describe the flow among them. Screenwriters and many creative writers do this by making a storyboard with pencil and paper, using an index card or drawing a rectangle for each scene, and creating a very rough sketch of the scene and a few words to describe what's going on there. You can show the transitions between scenes with an arrow and a brief description of when the transition takes place.
Figure 1.2 shows the storyboard I drew for V3, which is intentionally a very short game. The storyboard for a complete game will likely spread to multiple pages.
Figure 1.2 Preliminary game storyboard flow diagram
I also created a separate index card for each scene of the game, with a rough sketch of the graphics to be included. If you are creating your storyboard on a large piece of paper, you can just include the sketches right on the flow diagram. Figure 1.3 shows the index card for Level 1 of V3.
Figure 1.3 Index card for Level 1 of the storyboard