-
Notifications
You must be signed in to change notification settings - Fork 3
Game
The basic interface for building your own game. Provides basic functions called by Core.
You can choose to inherit from Game instead of Game. This will automatically provide a static Instance field of type T, which has to be the type of inheriting class itself. This effectively provides a singleton to your game instance (automatically assigned).
public class ExampleGame : Game<ExampleGame>
{
public float example;
}
ExampleGame.Instance.GetType(); // equates to typeof(ExampleGame)
ExampleGame.Instance.example = 3;Game.Startup() is called before entering the core loop when calling Core.Start(...). Should be used to initialize stuff, rather than the constructor.
Game.Shutdown() is called after exiting the core loop. Should be used to delete stuff, rather than the destructor. At least for things directly dependent on Core Modules.
Game.Update() is called every frame (as long as Time.Freeze(...) is not active). Use this to update everything in your game.
Game.Render() is called every frame. Use this to render everything in your game (See Graphics, Batch2D).
Game.Step() is called every frame. Use this as a direct extension of the core loop if you need to.