Seminar Computergrafik mit GameEngines: EventQueue (inspiriert von https://gameprogrammingpatterns.com/event-queue.html)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
930 B

2 years ago
#include "Listener.h"
void GameListener::accept(GameEvent *event) {
if (auto coinEvent = dynamic_cast<CoinCollectEvent *>(event))
OnCoinCollect(coinEvent);
if (auto dmgEvent = dynamic_cast<DamageEvent *>(event))
OnDamage(dmgEvent);
}
void InputListener::accept(InputEvent *event) {
2 years ago
if (auto mousePress = dynamic_cast<MousePressEvent *>(event))
mousePressed(mousePress);
if (auto mouseRelease = dynamic_cast<MouseReleaseEvent *>(event))
mouseReleased(mouseRelease);
if (auto mouseDoubleClick = dynamic_cast<MouseDoubleClickEvent *>(event))
mouseDoubleClicked(mouseDoubleClick);
if (auto mouseMove = dynamic_cast<MouseMoveEvent *>(event))
mouseMoved(mouseMove);
if (auto keyPress = dynamic_cast<KeyPressEvent *>(event))
keyPressed(keyPress);
if (auto keyRelease = dynamic_cast<KeyReleaseEvent *>(event))
keyReleased(keyRelease);
if (auto wheel = dynamic_cast<WheelEvent *>(event))
mouseWheel(wheel);
2 years ago
}