To start a project, extend the Game class and implement the DrawGame method. You initialize the engine by passing GameSettings, WindowSettings, FramerateSettings, and InputSettings to the constructor.
In the DrawGame override, you receive a ScreenInfo object (often named game) which provides access to the drawing area and input states like MousePos.
using System.Drawing;
using ShapeEngine.Color;
using ShapeEngine.Core;
using ShapeEngine.Core.Structs;
using ShapeEngine.Geometry;
using ShapeEngine.Geometry.RectDef;
namespace ShapeEngineProject;
public static class Program
{
public static void Main(string[] args)
{
var game = new MyGameClass
(
GameSettings.StretchMode("Shape Engine Game"),
WindowSettings.Default,
FramerateSettings.Default,
InputSettings.Default
);
game.Run();
}
}
public class MyGameClass : Game
{
public new static MyGameClass Instance => myInstance?? throw new NullReferenceException("Instance is not initialized!");
private static MyGameClass? myInstance;
public MyGameClass(
GameSettings gameSettings, WindowSettings windowSettings,
FramerateSettings framerateSettings, InputSettings inputSettings)
: base(gameSettings, windowSettings, framerateSettings, inputSettings)
{
myInstance = GetInstanceAs<MyGameClass>();
}
protected override void DrawGame(ScreenInfo game)
{
game.Area.Draw(new ColorRgba(Color.DarkOliveGreen));
game.Area.DrawLines(12f, new ColorRgba(Color.AntiqueWhite));
game.MousePos.Draw(24f, new ColorRgba(Color.Lime), 36);
}
}