diff --git a/Raylib-cs/types/Window.cs b/Raylib-cs/types/Window.cs
index e306632..26aafe6 100644
--- a/Raylib-cs/types/Window.cs
+++ b/Raylib-cs/types/Window.cs
@@ -5,34 +5,41 @@ namespace Raylib_cs;
public sealed class Window : IDisposable
{
- private static Window _instance;
+ public event OnInit Init;
+ public event OnUpdate Update;
+ public event OnDraw Draw;
+ public event OnClose Close;
+
+ private int _width;
+ private int _height;
+ private string _title;
- private Window(ConfigFlags flags, int width, int height, string title)
- {
- Raylib.SetConfigFlags(flags);
- Raylib.InitWindow(width, height, title);
- _instance = this;
+ public Window(int width, int height, string title) {
+ this._width = width;
+ this._height = height;
+ this._title = title;
}
-
- ///
- /// Gets an instance of the Window or creates a new one if it doesn't exist.
- ///
- /// The configuration flags for the window.
- /// The width of the window.
- /// The height of the window.
- /// The title of the window.
- /// An instance of the Window.
- public static Window Instance(ConfigFlags flags, int width, int height, string title)
- {
- return _instance ?? new Window(flags, width, height, title);
+
+ public void Run() {
+ Raylib.InitWindow(_width, _height, _title);
+ Init?.Invoke();
+
+ while (!ShouldClose()) {
+ Update?.Invoke();
+
+ Raylib.BeginDrawing();
+ Raylib.ClearBackground(Color.SKYBLUE);
+ Draw?.Invoke();
+ Raylib.EndDrawing();
+ }
+
+ Close?.Invoke();
+ Raylib.CloseWindow();
}
///
public bool ShouldClose() => Raylib.WindowShouldClose();
- ///
- public void Close() => Raylib.CloseWindow();
-
///
public void TakeScreenshot(string path) => Raylib.TakeScreenshot(path);
@@ -162,10 +169,13 @@ public sealed class Window : IDisposable
///
public string GetClipboardText() => Raylib.GetClipboardText_();
- public void Dispose()
- {
- if (!IsReady()) return;
- this.Close();
- _instance = null;
- }
+ public delegate void OnInit();
+
+ public delegate void OnUpdate();
+
+ public delegate void OnDraw();
+
+ public delegate void OnClose();
+
+ public void Dispose() { }
}
\ No newline at end of file