denyskryvytskyi / ElvenEngine

2D/3D game engine from scratch
MIT License
81 stars 6 forks source link

Event System introduced #2

Closed denyskryvytskyi closed 2 years ago

denyskryvytskyi commented 3 years ago

Brief overview

Implemented using Observer pattern without separate classes for Observer/Subject. There is global EventManager object to transfer our events to receivers. There is event queue that will be processed at the end on the game loop to avoid blocking events.

You can subsribe/unsubscribe to any event: Events::Subscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose)); Events::Unsubscribe<WindowCloseEvent>(EVENT_CALLBACK(Application::OnWindowClose));

Where Applciation::OnWindowClose is the member function with Derived from Event parameter: bool Application::OnWindowClose(const Events::WindowCloseEvent& e)

Benefits