1. Empty Game Application - Tutorial

Vortex2D.NET is based on application model architecture. Main game class is derived from Vortex.Game base class:

class EmptyGame : Vortex.Game {

Created game application can be run with following startup code which is usually placed in Program.cs file:

static class Program {
    static void Main() {
        using (EmptyGamegame = new EmptyGame()) {

Next step: prepare methods to put resource loading/freeing code. And also prepare methods for updating, rendering frame content. Now empty game application should look like this:

    class EmptyGame : Vortex.Game {
        ///<summary>Load() is method where most of resource loading code should be placed</summary>
        protected override void Load () {        

        ///<summary>Unload() is called before game exit. All resource should be freed here</summary>
        protected override void Unload () {

        ///<summary>Update() is called each frame to prcess some per-frame calculation like: AI, physics, animation etc</summary>
        protected override void Update (GameTime time) {

        ///<summary>Render() is called each frame to update graphics content of frame. All drawing code should be here</summary>
        protected override void Render (Canvas2D canvas) {
            //Canvas2D.Clear method forcess cleanup of drawing target. There are few more overloads to clear only part of target
            //ColorU is representation of 4-component color packed into Uint (byte-per component). It is most usable type of color

Running it you'll receive black window with FPS counter.

At the end of tutorial lets configure some properties of game window. Configuring of window parameters is easy. All you need is modify Game.Window object properties or call methods. Most of changes will be applied before next frame will be started. Window configuration code can be placed everywhere. Constructor of application class is good enough place:

public EmptyGame() {
    //configuring window size
    Game.Window.Size = new System.Drawing.Size(720, 500);
    //setting window title (it could be changed during game flow like all other properties)
    Game.Window.Title = "Empty Game Application";
    //changing of window location is desktop space. Now it is just a property.
    Game.Window.Location = new System.Drawing.Point(100, 100);
    //setting fullscreen/windowed mode
    Game.Window.Fullscreen = false;
    //limiting framerate setting vertical blank sync
    Game.Window.VerticalSync = true;

Last edited Dec 20, 2010 at 5:19 PM by AlexKhomich, version 10


No comments yet.