Export (0) Print
Expand All
23 out of 38 rated this helpful - Rate this topic

Starter Kit: Platformer

The Platformer Starter Kit is a near-complete, self-contained game solution that includes both game code and game assets. The game is a standard 2D platformer with levels, enemies, and collectable gems.

This starter kit is intentionally incomplete. Several nonessential features and systems are not finished. This makes it easier and quicker to understand the structure of the game, and how the pieces fit together to provide a rich gaming experience. The Platformer Starter Kit includes the following features:

  • Cross-platform support for Windows, Zune, and Xbox 360.
  • Control of the player character using either the keyboard or gamepad.
  • Simple physics modeling (falling and jumping) and dynamic collision checking.
  • Production-level sprite sheets, sound effects, and other game assets.
  • High and low resolution assets, and an additional content project containing audio assets.
  • New features from XNA Game Studio, such as the simple sound API and multiple content projects whose usage depends on the target platform.
Dd254918.Platformer_NearExit(en-us,XNAGameStudio.31).jpg

Figure 1.  Gameplay Screen for the Platformer Starter Kit

Player Controls

The player character is controlled using either the keyboard or gamepad.

ActionKeyboardGamepadZune
Run left, Run rightA, DLeft thumbstick or analog D-padDevice control pad (version 1) or Zune pad (version 2)
JumpSpace A Click the center of either the device control pad (version 1) or the Zune pad (version 2)

Platformer Code Architecture

The following is a list of classes shipped with the Platformer starter kit. The file containing the implementation for each class shares the name of the class. For example, Gem.cs contains the Gem class implementation.

NameDescription
Gem

Implements a floating gem in the game. Gems are collectable by the player, and are worth a set amount of points.

Gems are used to load, draw, and update a gem. For more information, see Basic Platformer Features.

Circle (structure) Implements a bounding circle for checking collision against gem objects. For more information, see Basic Platformer Features.
Tile (structure) Stores basic information about a game tile. For more information, see Basic Platformer Features.
TileCollision (enumeration) Stores the different collision types a tile can have: Passable, Impassable, Platform. For more information, see Basic Platformer Features.
AnimationPlayer (structure)

Implements playback of the animation stored by Animation.

For more information, see Intermediate Platformer Features.

Animation

Stores an animated texture. Used to animate the player character and enemy sprite sheets.

For more information, see Intermediate Platformer Features.

Enemy

Implements an enemy in the game. Used to load, draw, and update an enemy.

For more information, see Intermediate Platformer Features.

FaceDirection (enumeration) Stores the different directions an enemy can face. For more information, see Intermediate Platformer Features.
PlatformerGame

Implements major game components such as content and level loading, HUD management and display, and game object updating.

For more information, see Advanced Platformer Features.

Level

Implements a level in the game. A Level object contains a multi-dimensional array of tiles, a player character, a start and end location, point total, remaining level time, a list of gems, and a list of enemies.

For more information, see Advanced Platformer Features.

Player

Implements the player character. Used to load, draw, and update the character.

For more information, see Advanced Platformer Features.

RectangleExtensions Implements an extension to the standard XNA Framework structure Rectangle. For more information, see Advanced Platformer Features.

Execution Flow

Think of the execution flow of Platformer as follows:

  1. The next level is loaded. Important methods are PlatformerGame.LoadContent and PlatformerGame.LoadNextLevel.
  2. The game is updated using PlatformerGame.Update and Level.Update. If the player is dead or if time has expired, input is ignored and the game is in a pause state. If the player has reached the exit, the remaining time is converted to points. If there is still time and the player hasn't reached the exit location, the time remaining is decremented and all level objects are updated (player character, enemies, gems, and so on) using their Update methods. At this time, checks are also made for the player reaching the exit and falling off the edge of the screen.
  3. The gameplay screen is drawn using PlatformerGame.Draw. This method, in turn, calls Level.Draw and PlatformerGame.DrawHud.

    Level.Draw is responsible for drawing the tiles, player character, gems and enemies using calls to the Draw method of each previously-mentioned game object.

Exploring the Platformer Starter Kit

Basic Platformer Features
Discusses basic features of the Platformer Starter Kit and offers recommendations for making basic modifications to the Platformer game.
Intermediate Platformer Features
Discusses intermediate classes of the Platformer Starter Kit, and offers recommendations for modifying or extending Platformer features.
Advanced Platformer Features
Discusses advanced features of the Platformer Starter Kit, and offers recommendations for modifying or extending Platformer features.
Platformer: Adding Touch Support
Extends the base Platformer starter kit code by adding touch screen and accelerometer support for input.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.