© Ted Hagos, Mario Zechner, J.F. DiMarzio and Robert Green 2020
T. Hagos et al.Beginning Android Games Developmenthttps://doi.org/10.1007/978-1-4842-6121-7_5

5. Introduction to Game Development

Ted Hagos1 , Mario Zechner2, J. F. DiMarzio3 and Robert Green4
(1)
Makati, Philippines
(2)
Graz, Steiermark, Austria
(3)
Kissimmee, FL, USA
(4)
Portland, OR, USA
 

There are an estimated 2.8 million apps on Google Play (at the time of writing), and 300,000 of them are games. That’s a lot of games; and it will still grow. Anyone thinking of writing a novel game will be hard-pressed, considering that programmers have been writing games for a long time now. If you’re hunting for ideas for a new game, it might be best to survey the existing games; see what kinds of ideas you can pick and combine.

In this chapter, we’ll look at some of the popular games in Google Play. We’ll also discuss a high-level overview of what kind of functionalities we’ll need to bake into our game code. We’ll cover the following areas:
  • Game genres

  • Game engine

  • Game loop

A Quick Tour of Game Genres

If you looked at the Wikipedia page for game genres, you’ll see the many (and still growing) categories of games. A game genre is a specific category of games related by their gameplay characteristics. We won’t describe all the games here, but let’s look at some of the popular ones.

Casual Games

Casual games are fast becoming a favorite for both experienced and non-experienced gamers. These games usually have very simple rules, play techniques, and degree of strategy. You don’t need to commit extra-long hours for these games, nor do you need special skills to enjoy them; that’s probably the reason why these games are very popular, because they’re easy to learn and play as a pastime.

I’m sure you’ve seen some of these games already; you might have played a couple of them. Minion Rush (Figure 5-1) is a runner game, based loosely on the very popular Temple Run, where you guide a figure—in this case, a minion—through hoops and obstacles. Swipe left and the minion goes left, swipe right and it goes right, swipe down to slide, and swipe up to jump; it really is simple. There are many derivatives of this game, but the mechanics rarely changes. Usually, the objective is to run for as long as possible and collect some tokens along the way.
../images/340874_4_En_5_Chapter/340874_4_En_5_Fig1_HTML.jpg
Figure 5-1

Minion Rush

Another example of a casual game is Candy Crush Saga (Figure 5-2). It’s a “match three” game. The gameplay revolves around swapping two adjacent candies among several on the game board so that you can make a row or column of three matching colored candies. By the way, while Candy Crush Saga is considered a casual game, it also belongs to another category called puzzle games; sometimes, a game may belong to more than one category.
../images/340874_4_En_5_Chapter/340874_4_En_5_Fig2_HTML.jpg
Figure 5-2

Candy Crush Saga

Puzzle Games

Puzzle or logic games require the player to solve logic puzzles or navigate challenging locations such as mazes. This genre frequently crosses over with adventure, educational, or even casual games. I’m sure you’ve heard of Tetris (Figure 5-3) or Bejeweled; these two are the best examples I can think of for puzzle games.
../images/340874_4_En_5_Chapter/340874_4_En_5_Fig3_HTML.jpg
Figure 5-3

Tetris

Tetris is largely credited for popularizing the puzzler genre. Tetris, originally, came from the Soviet Union and came to life sometime in 1984. The goal in this game is simple; the player must destroy lines of block before the blocks pile up and reaches the top. A tetromino is the shape of the four connected blocks that falls from the top of the screen and settles at the bottom. There are generally seven kinds of tetrominoes (Figure 5-4). You can guide the tetrominoes as they fall; swiping left or right guides the blocks to the desired location, and (usually) double tapping rotates the tetrominoes.
../images/340874_4_En_5_Chapter/340874_4_En_5_Fig4_HTML.jpg
Figure 5-4

Tetrominoes

Bejeweled (Figure 5-5) is another popular puzzler. The goal is to clear gems of the same color, potentially causing a chain reaction; this is done by swapping one gem with an adjacent gem to form a horizontal or vertical chain of three or more gems of the same color. When chains are formed, the gems disappear and some other gems fall from the top to fill in the gaps—sometimes, “cascades” are triggered when chains are formed by the falling gems.
../images/340874_4_En_5_Chapter/340874_4_En_5_Fig5_HTML.jpg
Figure 5-5

Bejeweled

As you can see from the Tetris and Bejeweled examples, matchers make for good puzzle gameplay; but there are other kinds of puzzlers. Take “Cut the Rope” (Figure 5-6) by ZeptoLab as an example; it’s a physics puzzler. The goal of the game is to feed the candy to “Om Nom” (the little green creature). The candy must be guided toward Om Nom by cutting ropes the candy is attached to; the candy may be blown or put inside bubbles, so it avoids obstacles. Every game object is physically simulated to some degree. The game is powered by Box2D, a 2D physics engine.
../images/340874_4_En_5_Chapter/340874_4_En_5_Fig6_HTML.jpg
Figure 5-6

Cut the Rope

Action Games

Action games usually require hand-eye coordination and motor skills. These games center around a player who is in control of most of the action. This genre has many subgenres such as platformers, shooting games, fighting games, stealth, survival games, battle royale, and rhythm games.

Platformers usually involve a character that jumps and climbs to navigate the environment. There are usually enemies and obstacles that the character must avoid. The most popular platform games are usually released either in consoles or PCs (Mario Bros., Donkey Kong, Crash Bandicoot, Sonic Mania, Limbo, etc.), but some platformers are making their way into Google Play (Adventure Island, Blackmoor 2, Dandara, etc.).

Shooter games (or simply, shooters) are another popular subgenre of action games. The genre is very descriptive, you can guess what these games are all about just from their genre, and you would be right; you shoot things, people, aliens, monsters, zombies, and so on. The player uses a range of weapons to participate in action, which takes place at a distance. This genre is usually characterized by violent gameplay and lethal weaponry (with some notable exceptions like Splatoon, which have a nonviolent objective and gameplay). Some of the popular shooter games in Google Play are Call of Duty mobile, Fortnite, Hitman Sniper, PUBG mobile, Critical Ops, Dead Effect 2, and Gigantic X, to name a few.

Tower Defense Games

Tower defense is a subgenre of strategy games. Strategy games focus on gameplay which requires skillful and careful thinking and planning in order to achieve victory. In most strategy games, the player is given “god-like” view of the game world so they can control the units in their command, either directly or indirectly.

Tower defense game play typically features an evil force that sends out waves of critters, zombies, balloons, or what have you. Your task is to defend some strategic area in the game world (your tower) by mounting defenses, whether that be turrets, monkeys, guns, and so on. These defenses will shoot the incoming waves of the enemy, and you get points for each kill. The points are converted into game currency that you can use either to upgrade your weapons or buy new weapons.

At the time of writing, the popular tower defense games in Google Play are Bloons TD 6, Defenders 2, Defense Zone 3, Digfender, Element TD, Kingdom Rush, and Grow Castle, to name a few.

This is in no way a compendium of the game genres; it’s a small list of what kinds of games you can find in Google Play. If you’re looking for an inspiration for your next game (or first game), try to play the games analytically, and set aside the entertainment part. Do it clinically. Try to get a feel of how the game flows and try to deconstruct it in your mind. That may give you some ideas for your game.

Game Engine

Once you have an idea what game you want to build, and presumably, you’ve gone through the exercise of designing your game through storyboarding, mocking the graphics, and drawing some screen wireframes—you know, the planning stage—you probably want to spend some time on how to organize the code. The organization of the code is what makes up the game engine and the game loop.

At the core of every game is the game engine . This is the code that powers the game; this is the one that handles all the grunt work. A typical game engine will handle the following tasks:
  • Window management

  • Graphics rendering

  • Animation

  • Audio

  • Collision detection

  • Physics

  • Threading and memory

  • Networking

  • Input/output

  • Storage

The game loop is a block of code within the game engine. As its name suggests, it loops. It runs repeatedly and perpetually; it doesn’t stop until the player quits. You may have heard gamers talked about frame rates before; the speed at which your game loop can run affects the frame rate of the game. The faster your code executes within the loop, the more responsive it will be and the smoother the game will be.

A typical game loop does the following:
  • Get inputs from the user—This is the command interpreter; you need to set up your code to listen to user inputs, whether they be double taps, long clicks, button clicks, swipes, gestures, keyboard inputs, or others. These inputs affect the characters and the overall game, for example, if the game was Minion Rush or Temple Run, swiping left, right, up, or down moves the runner.

  • Collision detection—This is where you track the characters as they move through the game world. When they reach the edges of the game world, you decide what to do with the character. Collision detection is also where you test if the character has bumped into obstacles.

  • Draw and move the background—This is where you draw the game world, at least part of it that should be visible to the player.

  • Move the characters as a response to the user input.

  • Play sound effects as interesting events happen to the character or within the game world.

  • Play background music—This isn’t the same as playing sound effects. The background music persists throughout a level, so it needs to be continuous. This is where your knowledge of threads will come in handy.

  • Track the player’s score—As the game progresses, the player will accumulate points. You can store the game stats locally using a local storage. In case you need to update a leaderboard in the cloud, you need to use the networking APIs of Android. Tracking the player’s score might also involve displaying a dedicated screen (an Activity or a Frame in Android) where the scores are tallied.

This isn’t an exhaustive or definitive list of what you need to address in code, but it’s a start. The number of things you need to do in the game loop and the game engine will increase or decrease depending on the complexity of the game.

Key Takeaways

  • There is already a myriad of games. Your next game inspiration could come from existing games. Try playing the game analytically, clinically, and divorced from the entertainment aspect. Dissect them to get an idea of how they flow.

  • Smoothness of the game experience is heavily affected by what you do inside the game loop. The faster the loop executes, the snappier your game is.

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

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