当前位置: 首页>>代码示例>>C++>>正文


C++ ControllerInterface::runEventHandler方法代码示例

本文整理汇总了C++中ControllerInterface::runEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ ControllerInterface::runEventHandler方法的具体用法?C++ ControllerInterface::runEventHandler怎么用?C++ ControllerInterface::runEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ControllerInterface的用法示例。


在下文中一共展示了ControllerInterface::runEventHandler方法的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;
	}
开发者ID:Orangeyness,项目名称:B-B-rebirth,代码行数:81,代码来源:main.cpp


注:本文中的ControllerInterface::runEventHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。