Torque 2D/GenreTutorials/PlatformerOverview

From TDN

Image:Alert.png This article or section needs updating.

Parts of this article or section have been identified as out of date.
While the information may be useful, be advised that it may be inaccurate, buggy or erroneous.

Reason: The majority of this tutorial series was written in a prerelease version of TGB and no longer works. Please follow this link for a current platformer tutorial: TGB/Tutorials/Platformer

If you are able to revise this information, please do so and remove this 'update' flag when finished.


Contents

Platformer Basics


The platformer genre is usually characterized by gameplay in which the main focus is navigating a character through levels as opposed to destroying an enemy. Really, though, the concepts of a platformer can be applied to almost any side-scrolling 2D game. We will need a character that can walk around and jump, with the possibility for other movement options. There will probably be at least a few enemies and a way to attack them and be attacked by them. We will need a basic side scrolling camera system that follows the main character through the levels. Even with these basic ideas set, there is a ton of leeway in how to implement them as the implementation is highly dependent on the design of your game.





Design


The most important thing to think about when designing a platformer is the control. The difficulty of moving the character through the levels should be a result of the level design, not a bad control scheme.

Some things to think about: How fast can the character move? How high can it jump? Can it be controlled while in the air? What other ways can it move around (for example: spin dash from Sonic, p-wings from Mario, morph ball from Metroid)?

As a general rule, the faster your character can move, the less precise the movement will be, and the levels and objectives should be designed accordingly. In a fast paced game, the player will not want to have to hunt for items and navigate mazes. But, in a slow paced game these things are necessary to keep the player from getting bored.

Another very important and often unheralded part of the design is the camera system. There doesn’t seem to be much to work with here, but there are a couple of important choices to be made. Any camera system you decide on will be side scrolling because that is inherent to a 2D game. The way in which it scrolls is what must be designed.

The way the camera should behave depends on the way the game is meant to be played. If the game is fast paced, you will want the player to be able to see a long way in front of their character. You can accomplish this through zooming out, or positioning the character farther back in the screen. Most often, the character will be in the bottom left third of the screen. If your game is designed more around exploration, though, you may want the player to see equally in all directions by placing the character in the center of the screen.

You also must decide how the camera tracks the player. You most definitely want it to follow horizontal movement, but you may not want it to track vertical movement. In Super Mario Brothers, the camera never moves vertically because the level design doesn’t require it. There is also the option of how fast the camera tracks. In Sonic the Hedgehog, the camera follows Sonic with a slight lag to emphasize the sense of speed.

Of course, the camera doesn’t necessarily have to follow the player. The player could be bound to the camera area and forced to follow its path like some levels in Super Mario Brothers 3.

As with the control scheme, a good camera system will be one that the player doesn't notice.





Prerequisites


This is a getting started tutorial, so it is aimed at beginners to game development. I do assume, though, that you have spent some time learning the basics of Torque Script. You won’t have to figure anything specific out on your own, I will be providing all of the code, but you will have to know the basics to really understand what is going on. If you have completed and understood the TGB Basic Tutorial, you should have no problem here. If you have no previous experience with TorqueScript, you should check out this article before continuing.





Topics We Will Cover


These tutorials will cover just the basic concepts. It is my goal to provide you with a core code base, and a core understanding, from which you can build a complete game. Here is the complete list of tutorials and the topics covered in each one:

Using Tile Maps to Construct Levels

  • Project Setup and Tile Map Introduction
  • Designing Levels
  • Creating Tile Sets
  • Using Brushes
  • Building Levels
  • Using Tile Layers in the Level Builder


Adding User Input and Basic Movement

  • Action Maps
  • Moving Horizontally
  • Jumping
  • Air Control


Creating a Scrolling Camera System

  • Using Script Objects
  • Tracking an Object
  • Setting View Limits
  • Auto Scrolling


Animating the Player

  • Creating the Images
  • Loading animations with Datablocks
  • Scripting Animations with a State Machine
  • Adding Additional Animation States


Scripting Enemies and AI

  • Creating the Enemy Object
  • AI Basics
  • Patrolling
  • Giving the AI Sight
  • Chasing
  • Expanding the AI


Winning and Losing Conditions

  • Being Defeated by Enemies
  • Defeating Enemies
  • Triggers
  • Falling to your death


Implementing Level Progression

  • Creating a Level Format
  • Loading and Unloading Levels


Building a User Interface

  • Constructing an in Game Interface
  • Creating Menus
  • Making a Level Selection GUI
  • Tieing Them all together with Script


Additional Topics