mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Implemented WindowsWindow and EventCallback
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using GlitchyEngine.Platform.Windows;
|
||||
using GlitchyEngine.Events;
|
||||
|
||||
namespace GlitchyEngine
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
private Window _window ~ delete _;
|
||||
private bool _running;
|
||||
private bool _running = true;
|
||||
|
||||
public bool IsRunning => _running;
|
||||
|
||||
@@ -13,16 +14,29 @@ namespace GlitchyEngine
|
||||
{
|
||||
// Todo: make Platform independent
|
||||
_window = new WindowsWindow(WindowDescription());
|
||||
_window.EventCallback = new => OnEvent;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
_running = true;
|
||||
|
||||
while(_running)
|
||||
{
|
||||
_window.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEvent(Event e)
|
||||
{
|
||||
EventDispatcher dispatcher = scope .(e);
|
||||
dispatcher.Dispatch<WindowCloseEvent>(scope => OnWindowClose);
|
||||
|
||||
Log.EngineLogger.Trace("{}", e);
|
||||
}
|
||||
|
||||
public bool OnWindowClose(WindowCloseEvent e)
|
||||
{
|
||||
_running = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user