C# Class Source.Game1

This is the main type for your game.
Inheritance: Microsoft.Xna.Framework.Game
显示文件 Open project: HarkerGameDev/TheGame Class Usage Examples

Public Properties

Property Type Description
currentPlatform System.Platform
drops List
fontSmall Microsoft.Xna.Framework.Graphics.SpriteFont
obstacles List
particles List
platforms List
playerControls List
players List
rand System.Random
smear Microsoft.Xna.Framework.Graphics.Texture2D
whiteRect Microsoft.Xna.Framework.Graphics.Texture2D

Public Methods

Method Description
Game1 ( ) : System
ToggleButton ( PlayerIndex playerIndex, Buttons button ) : bool
ToggleKey ( Keys key ) : bool

Protected Methods

Method Description
Draw ( GameTime gameTime ) : void

This is called when the game should draw itself.

Initialize ( ) : void

Allows the game to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.

LoadContent ( ) : void

LoadContent will be called once per game and is the place to load all of your content.

UnloadContent ( ) : void

UnloadContent will be called once per game and is the place to unload game-specific content.

Update ( GameTime gameTime ) : void

Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.

Private Methods

Method Description
CheckPlayer ( float deltaTime ) : void

Updates player and checks if the user is off the level, and resets the player if it is. Also updates the camera position. Basically, the non-collision update for the game

DrawBackground ( Vector2 averagePos ) : void
DrawCharacter ( ) : void
DrawGame ( double deltaTime ) : void
DrawRect ( Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale ) : void

Draws a rectangle. Make sure this is called AFTER spriteBatch.Begin()

DrawScene ( double deltaTime, Vector2 averagePos ) : void
HandleEditLevel ( ) : void

Handles all keypresses for editing a level. These are the controls: - Press 'E' to enter edit level mode. - Shift-drag to select a platform (move your mouse slowly) - Backspace to delete selected platform - Alt-drag to modify currently selected platform - Tap left, right, up, or down to move selected platform - Ctrl-drag to create a new platform - Ctrl-S to save your current level as a new level in the Levels folder - Ctrl-O to open the last level -- NOTE, this will override ANY changes you made, so be careful - + and - zoom in and out - Drag mouse with nothing held down to pan camera - Press f when a floor is selected to change its solid state

HandleInput ( float deltaTime ) : void

Handles all keyboard and gamepad input for the game. Moves all players and recalculates wobble-screen.

HandlePlayerInput ( Player player, int controller, float deltaTime ) : void

Handles input for a single player for given input keys

LoadBackground ( int loadLevel ) : void

Loads a level and stores it into background

LoadLevel ( int loadLevel ) : void
LoadReplay ( int replay ) : void
LoadSettings ( ) : void
LoadUI ( Menu type ) : void
ParseButtons ( ) : void
ProjectPointToLine ( Vector2 start, Vector2 end, Vector2 point ) : float

Projects a point onto a line and returns the progress along that line segment.

Raycast ( Vector2 start, Vector2 dir ) : float

Casts a ray from start in the given direction, returning the number of "dir" vector it takes to get to the closest contact

Reset ( ) : void
SaveLevel ( int saveLevel ) : void
SaveSettings ( ) : void
StartGame ( ) : void
UpdateMenu ( double elapsedTime ) : void
graphics_DeviceCreated ( object sender, EventArgs e ) : void
graphics_PreparingDeviceSettings ( object sender, Microsoft.Xna.Framework.PreparingDeviceSettingsEventArgs e ) : void
wobbleScreen ( float amplifier ) : void

Method Details

Draw() protected method

This is called when the game should draw itself.
protected Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime Provides a snapshot of timing values.
return void

Game1() public method

public Game1 ( ) : System
return System

Initialize() protected method

Allows the game to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.
protected Initialize ( ) : void
return void

LoadContent() protected method

LoadContent will be called once per game and is the place to load all of your content.
protected LoadContent ( ) : void
return void

ToggleButton() public method

public ToggleButton ( PlayerIndex playerIndex, Buttons button ) : bool
playerIndex PlayerIndex
button Buttons
return bool

ToggleKey() public method

public ToggleKey ( Keys key ) : bool
key Keys
return bool

UnloadContent() protected method

UnloadContent will be called once per game and is the place to unload game-specific content.
protected UnloadContent ( ) : void
return void

Update() protected method

Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.
protected Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime Provides a snapshot of timing values.
return void

Property Details

currentPlatform public_oe property

public Platform,System currentPlatform
return System.Platform

drops public_oe property

public List drops
return List

fontSmall public_oe property

public SpriteFont,Microsoft.Xna.Framework.Graphics fontSmall
return Microsoft.Xna.Framework.Graphics.SpriteFont

obstacles public_oe property

public List obstacles
return List

particles public_oe property

public List particles
return List

platforms public_oe property

public List platforms
return List

playerControls public_oe property

public List playerControls
return List

players public_oe property

public List players
return List

rand public_oe property

public Random,System rand
return System.Random

smear public_oe static_oe property

public static Texture2D,Microsoft.Xna.Framework.Graphics smear
return Microsoft.Xna.Framework.Graphics.Texture2D

whiteRect public_oe static_oe property

public static Texture2D,Microsoft.Xna.Framework.Graphics whiteRect
return Microsoft.Xna.Framework.Graphics.Texture2D