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.
43 lines
1.0 KiB
43 lines
1.0 KiB
2 years ago
|
#include <QApplication>
|
||
|
#include <QWidget>
|
||
|
#include <iostream>
|
||
|
#include "Queue.h"
|
||
|
#include "Audio.h"
|
||
|
#include "FileManager.h"
|
||
|
#include "Player.h"
|
||
|
|
||
|
using std::cout, std::endl;
|
||
|
|
||
|
auto audioManager = new Audio;
|
||
|
auto fileManager = new FileManager;
|
||
|
auto gameQueue = new GameQueue;
|
||
|
auto inputQueue = new InputQueue;
|
||
|
|
||
|
int main(int argc, char * argv[]){
|
||
|
QApplication app(argc, argv);
|
||
|
|
||
|
/*
|
||
|
for (int i = 0; i < 100'000; i++)
|
||
|
audioManager->playSound(1, i);
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
for (int i = 0; i < 10'000; i++){
|
||
|
fileManager->readFile("path" + std::to_string(i), [](const std::string& content){
|
||
|
std::cout << content << std::endl;
|
||
|
});
|
||
|
fileManager->writeFile("path" + std::to_string(i), "some content" + std::to_string(i));
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
auto player = new Player;
|
||
|
gameQueue->registerListener(player);
|
||
|
gameQueue->submitEvent<CoinCollectEvent>(new CoinCollectEvent);
|
||
|
gameQueue->submitEvent<DamageEvent>(new DamageEvent);
|
||
|
inputQueue->submitEvent<InputEvent>(new InputEvent);
|
||
|
|
||
|
QWidget window;
|
||
|
window.show();
|
||
|
|
||
|
return QApplication::exec();
|
||
|
}
|