First Game - NocturnalWisp/Tynted-Engine GitHub Wiki

Getting Started

So, hopefully you have a good grasp upon the way the Game and Scenes work. As a first project, we will be building upon it over time. Only start on this after you have completed the setup tutorial.

Creating the Game Class

This is fairly easy. Just start off by creating a new class that inherits from game.

using Tynted;

public class YourGameName : Game
{
    public YourGameName(GameOptions options) : base(options) { }
}

Overridables

Now you can override the three main functions.

using Tynted;
using Tynted.SFML.Graphics;

public class YourGameName : Game
{
    public YourGameName(GameOptions options) : base(options) { }

    public override void Initialize()
    {
        base.Initialize();
    }

    public override void Update(GameTime gameTime)
    {
        base.Update(gameTime);
    }

    public override void Draw(RenderWindow renderWindow)
    {
        base.Draw(renderWindow);
    }
}

Adding An Entity

Now we have the shell of the game, let's put some entities in to add a little flavor. I have also removed the unnecessary functions, as we do not need them.

using Tynted;
using Tynted.Components;
using Tynted.SFML.Graphics;
using Box2DNet.Common;

public class YourGameName : Game
{
    public YourGameName(GameOptions options) : base(options) { }

    public override void Initialize()
    {
        base.Initialize();

        //Create the entity.
        ECSManager.CreateEntity("Test1");
        
        //Make sure you have a texture in your /Res/ folder
        var texture = new Texture("Res/img.png");
        
        //Add Components to the entity "Test1".
        ECSManager.RegisterEntityComponents(new List<EntityComponentIdentifier>()
        {
            new EntityComponentIdentifier("Test1", new Transform(new Vec2(200, 200))),
            new EntityComponentIdentifier("Test1", new SpriteRenderee(texture))
        });
    }
}

Connecting With the Program

Now that the game class is complete, we can head over to the Program.cs and update it to actually run the game.

using Tynted;

class Program
{
	static void Main(string[] args)
	{
		using (Game game = new YourGameName(GameOptions.Default))
		{
			game.Run();
		}
	}
}

Congratulations

You have completed the first part! You should now be able to run it, and see your image on the screen. Check out how to create your own systems.