Platformer

# 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, Windows Phone, 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.

Action | Keyboard | Gamepad | Windows Phone
--- | --- | --- | ---
Run left, Run right | A, D | Left thumbstick or analog D-pad | TILT device
Jump | Space | A | TAP
Exit Game | ESC or ALT+F4 | BACK | BACK

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.

Name | Description
--- | ---
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.
Circle (structure) | Implements a bounding circle for checking collision against gem objects.
Tile (structure) | Stores basic information about a game tile.
TileCollision (enumeration) | Stores the different collision types a tile can have: Passable, Impassable, Platform.
AnimationPlayer (structure) | Implements playback of the animation stored by Animation.
Animation | Stores an animated texture. Used to animate the player character and enemy sprite sheets.
Enemy | Implements an enemy in the game. Used to load, draw, and update an enemy.
FaceDirection (enumeration) | Stores the different directions an enemy can face.
PlatformerGame | Implements major game components such as content and level loading, HUD management and display, and game object updating.
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.
Player | Implements the player character. Used to load, draw, and update the character.
RectangleExtensions | Implements an extension to the standard XNA Framework structure Rectangle.

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.