Jake on the mysterious planet – the feature list

We know the core components that we will need to develop to make this game work. We also have a rough idea about the game.

What's next? Another good step forward would be to write down the game's feature list and talk about each of the steps in detail.

Here is the feature list:

  • Procedural level generation with infinite gameplay
  • An animated 2D character with 2D physics
  • Mouse and touch controls
  • Collectables and storing the player's data
  • A scoring system with a storage of high score
  • UI

Let's talk about each of these features to make sure you understand what they are.

Procedural level generation

In every game, the level is a key component. It's the environment in which the player moves around and enjoys the game. In this case, we have a flat 2D level scrolling from right to left.

As Jake on the mysterious planet is an infinite scroller game, we don't know how big the level has to be. The player can play for just 10 seconds, or they can be really good at this game and run for a long time. This is the main reason we want to divide the level into movable pieces and generate it during gameplay.

It will work very simply. Once the player travels through the level, the level generator will spawn a new piece of the level in front of the player and destroy the level pieces that are far behind the player. This simple concept will grant the player infinite gameplay.

Take a look at this sketch:

Procedural level generation

The gray box represents our Main Camera in 3D space.

The green boxes represent moving pieces of the level. They spawn near the purple line and are destroyed once they touch the red line. I hope this concept makes sense to you. Don't worry about planning to code this at all as of now. Remember that we are planning the game. We are not in the active production phase yet. The more you think about the mechanics and how it can work, the better. There will always be a lot of uncertainty while planning, and some solutions that you pick at the planning stage might not work. That's fine! Let's stay open-minded with the game, while at the same time, try to plan as much as we can.

An animated 2D character

So, we are creating a 2D game in a 3D game engine. Yes, why not? Unity gives us a lot of brilliant features for creating 2D games. We will use Unity's built-in animation system to animate Jake. We will try to add animations for:

  • Running
  • Jumping
  • Falling
  • Flying in his spaceship

If you haven't used the Mecanim system in Unity to manage animations yet, I encourage you to take a look at Unity's official tutorials. Anyway, we will cover some basics in this book, too.

Physics

For gravity, physics, collision detection, and triggering of events, we will use built-in 2D physics components, such as Rigidbody2D. As our game is really simple and this book is about learning C#, we will try to keep the physics as simple as possible. In fact, we will just implement gravity and simply check whether our character is on the ground. These two physics mechanics are the absolute minimum for any platform game, and you will be able to reuse most of the code that you write for this.

Mouse and touch controls

We need to give our user a way to control the game. Yet again, simplicity is the key here. I believe we can use the built-in input system and make it universal for standalone platforms and mobile devices. The user will be able to use their mouse and touchscreen. We will possibly use clicks for jump mechanics, and that's it!

Collectables and obstacles

Our character will travel through the level. We will add the ability for him to collect stuff such as coins.

Jake can also be killed by obstacles. To make this work, we will use the built-in Unity physics and write some easy-to-use classes.

If you search in the Unity reference documentation for MonoBehaviour, you will find some useful methods called automatically by Unity physics, such as OnTriggerEnter, OnCollisionEnter, and so on. I don't want to go too much into the details of how this will work, but I want you to understand the principle.

Collectables and obstacles

On the left-hand side of the image, we have our character game object. It will contain a RigidBody component in order to enable simple gravity physics and physics events.

As soon as the RigidBody collider overlaps the coin trigger, the OnTriggerEnter method on the MonoBehaviour attached to the RigidBody game object will be executed automatically. I realize that this might feel a bit complicated, so don't trouble yourself about it too much yet. Once we get that far, I will explain it in much greater detail.

Scoring

Our game is very simple, so we should also keep the scoring system simple. The player's score will be calculated based on the distance traveled from the beginning of the level. The top score is technically infinite. You will learn how to store and retrieve the user's high score.

UI – the user interface

As this book covers the basics, we should first explain what a user interface is. A user interface is everything on the screen that the user interacts with to control the game. So, all buttons, text, and so on are parts of a UI system.

Unity introduced a brilliant UI system with version 4.6. We will focus on the built-in system instead of using any third-party package. Why? Simply because we should learn about the built-in tools that Unity offers.

The game will be divided into a few views, as follows:

  • Main menu view: This is the first view that the user sees when the game is loaded:
    UI – the user interface

    As you can see, the Main Menu view will be very simple. It will contain only the Title and the Play button. The Play button will take the user to the next view. We will possibly add a nice background also, maybe an animated one. Let's keep the background planning open for this view. We can decide on that later.

  • In-game view: This will be visible during the gameplay only:
    UI – the user interface

    This is more or less what we want our user to see during the actual gameplay stage. The top-left corner will be occupied by some text. One part of it will say Score, and immediately underneath it we will display the current score. Analogically, the top-right corner will display the highest score ever achieved by the player.

    The top center of this view seems to be a good spot for a coin counter. The coin counter will display a coin symbol right next to a text label that shows the currently collected coins. The view won't have any background as it will be filled by the game itself! I hope this makes sense.

  • Game Over view: This will be shown after the game, when the playable character dies:
    UI – the user interface

    When the player dies, we will move the focus to the Game Over view, most likely displaying the elements shown in the preceding figure. A massive Game Over message will be shown, followed by the score achieved and the count of coins collected. The user will have to make a choice here to either click on Play again or go to the main menu.

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

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