feat: added basic window, input & drawing

This commit is contained in:
2026-01-28 22:38:17 +03:00
parent 18ac6b23fd
commit 129aae563e
12 changed files with 754 additions and 96 deletions

View File

@@ -7,6 +7,7 @@ using Engine.Integration.SDL3;
using Engine.Serializers.Yaml;
using Engine.Systems.Network;
using Engine.Systems.Time;
using MyUniverse.Shared.Behaviours;
Universe universe = new();
@@ -43,22 +44,51 @@ desktopParent.AddChild(universe.InstantiateUniverseObject().SetUniverseObject("T
Sdl3Window window = Engine.Core.Factory.BehaviourFactory.Instantiate<Sdl3Window>();
window.Title = "MyUniverse";
window.Size = new(800, 600);
window.Mode = WindowMode.BorderlessWindowed;
window.Mode = WindowMode.Windowed;
Sdl3Window window2 = Engine.Core.Factory.BehaviourFactory.Instantiate<Sdl3Window>();
window2.Title = "MyUniverse 2";
window2.Size = new(400, 300);
window2.Mode = WindowMode.Windowed;
universe.InstantiateUniverseObject().SetUniverseObject("SDL3 Manager", desktopParent)
.BehaviourController.AddBehaviour<Sdl3WindowManager>()
.BehaviourController.AddBehaviour<Sdl3KeyboardInputs>()
.BehaviourController.AddBehaviour<Sdl3GameInputs>();
IUniverseObject windowUO = universe.InstantiateUniverseObject().SetUniverseObject("SDL3 Window", desktopParent);
windowUO.BehaviourController.AddBehaviour<Transform2D>();
windowUO.BehaviourController.AddBehaviour<Engine.Systems.Graphics.DrawableShape2D>(Shape2D.Square, new ColorRGB(0, 0, 128));
windowUO.BehaviourController.AddBehaviour(window);
windowUO.BehaviourController.AddBehaviour<Sdl3Camera2D>().Zoom = 20f;
windowUO.BehaviourController.AddBehaviour<Sdl3TriangleBatch>();
windowUO.BehaviourController.AddBehaviour<CameraController2D>();
IUniverseObject windowUO2 = universe.InstantiateUniverseObject().SetUniverseObject("SDL3 Window 2", desktopParent);
windowUO2.BehaviourController.AddBehaviour<Transform2D>().Rotation = 45f;
windowUO2.BehaviourController.AddBehaviour<Engine.Systems.Graphics.DrawableShape2D>(Shape2D.Square, new ColorRGB(128, 0, 0));
windowUO2.BehaviourController.AddBehaviour(window2);
windowUO2.BehaviourController.AddBehaviour<Sdl3Camera2D>().Zoom = 20f;
windowUO2.BehaviourController.AddBehaviour<Sdl3TriangleBatch>();
windowUO2.BehaviourController.AddBehaviour<LinearRotator>();
// Testing Start
TickerStopwatch tickerStopwatch = windowUO.BehaviourController.AddBehaviour<TickerStopwatch>();
tickerStopwatch.Period = 5f;
tickerStopwatch.OnTick.AddListener(sender =>
{
if (window.IsInitialized)
windowUO.BehaviourController.RemoveBehaviour(window);
else
windowUO.BehaviourController.AddBehaviour(window);
});
tickerStopwatch.Start();
// TickerStopwatch tickerStopwatch = windowUO.BehaviourController.AddBehaviour<TickerStopwatch>();
// tickerStopwatch.Period = 5f;
// tickerStopwatch.OnTick.AddListener(sender =>
// {
// if (window.IsInitialized)
// windowUO.BehaviourController.RemoveBehaviour(window);
// else
// windowUO.BehaviourController.AddBehaviour(window);
// });
// tickerStopwatch.Start();
// universe.InstantiateUniverseObject()
// .SetUniverseObject("Square")
// .BehaviourController.AddBehaviour<Transform2D>()
// .BehaviourController.AddBehaviour<Engine.Systems.Graphics.DrawableShape2D>(Shape2D.Square, new ColorRGB(255, 255, 0));
// Testing End
universe.Initialize();
@@ -82,6 +112,7 @@ while (true)
timeSinceStart += updateTimeSpan;
universe.Update(new(timeSinceStart, updateTimeSpan));
universe.Draw();
lastRun = now;
System.Threading.Thread.Sleep(1);