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.
 
 

25 lines
953 B

#include "Listener.h"
void GameListener::accept(GameEvent *event) {
if (auto wallJumpEvent = dynamic_cast<WallJumpEvent *>(event))
OnWallJumped(wallJumpEvent);
if (auto wallCrashEvent = dynamic_cast<WallCrashEvent *>(event))
OnWallCrashed(wallCrashEvent);
}
void InputListener::accept(InputEvent *event) {
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);
}