本文整理汇总了C++中ControllerInterface::iniController方法的典型用法代码示例。如果您正苦于以下问题:C++ ControllerInterface::iniController方法的具体用法?C++ ControllerInterface::iniController怎么用?C++ ControllerInterface::iniController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControllerInterface
的用法示例。
在下文中一共展示了ControllerInterface::iniController方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
try {
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_KEYBOARD_STATE keystate;
ALLEGRO_EVENT_QUEUE *events;
ALLEGRO_TIMER *updateTimer;
if (!al_init()) {
cout << "Allegro: failed to init" << endl;
return 1;
}
al_install_keyboard();
al_init_primitives_addon();
al_init_image_addon();
updateTimer = al_install_timer(1.0 / 60);
events = al_create_event_queue();
al_register_event_source(events, al_get_keyboard_event_source());
al_register_event_source(events, al_get_timer_event_source(updateTimer));
al_start_timer(updateTimer);
ControllerInterface* currentCon = new InitalController();
stack<ControllerInterface*> conStack;
while(currentCon != NULL) {
if (currentCon->getDisplaySettingsChanged()) display = updateDisplay(display, events, currentCon);
if (1.0 / currentCon->getDesiredFrameRate() != al_get_timer_speed(updateTimer)) al_set_timer_speed(updateTimer, 1.0 / currentCon->getDesiredFrameRate());
ControllerReturn* rtn = currentCon->runEventHandler(events);
if (rtn->finished) {
delete currentCon;
if (rtn->addController != NULL) {
currentCon = rtn->addController;
display = updateDisplay(display, events, currentCon);
currentCon->iniController();
}
else
{
if (!conStack.empty()) {
currentCon = conStack.top();
display = updateDisplay(display, events, currentCon);
currentCon->iniController();
conStack.pop();
}
else
{
currentCon = NULL;
}
}
}
else
{
if (rtn->addController != NULL) {
conStack.push(currentCon);
currentCon = rtn->addController;
display = updateDisplay(display, events, currentCon);
currentCon->iniController();
}
}
delete rtn;
}
al_destroy_event_queue(events);
if (display != NULL) al_destroy_display(display);
al_uninstall_system();
}
catch (string str) {
cout << "Exception occured: " << str << endl;
}
catch (char const* str) {
cout << "Exception occured: " << str << endl;
}
return 0;
}