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


C++ EventHandler::init方法代码示例

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


在下文中一共展示了EventHandler::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

void main()
{
	LOG("Burger Bash running on the Sifteo SDK\n");
	
	EventHandler eventHandler;
	eventHandler.init();
	
	// Plate cube initialize
	pCube.init(gNumCubes - 1);
	
	// Init all other cubes
	for (int i = 0; i < gNumCubes - 1; i++)
	{
		cubes[i].init(i);
	}
	
	// Game loop
	TimeStep ts;
    while (1) {
		for (int i = 0; i < gNumCubes; i++)
		{
			cubes[i].update();
		}
		
        System::paint();
        ts.next();
    }
    
    //AudioTracker::play(Music);
}
开发者ID:andrebelanger,项目名称:BurgerBash,代码行数:30,代码来源:main.cpp

示例2: main

void main()
{
    GameState state = StateResults;
	Random randomGen;
  	randomGen.seed();

    for (unsigned i = 0; i < arraysize(cubeVideo); i++)
    {
        InitCube(i, i);
    }

    EventHandler handler;
    handler.init();

    TimeStep ts;
    float Delay;
    bool isDone;

    while (1)
    {
        switch (state)
        {
            case StateInit:
				CurrentGame->init();
				Delay = 3;
				playSfx (CountSound);
				LOG ("Init\n");
				state = StateStart;
            break;

            case StateStart:
                Delay -= float(ts.delta());

                if (Delay <= 0)
                {
                    CurrentGame->start();
                    for (unsigned i = 0; i < gNumCubes; i++)
                    {
                        CurrentGameCube[i]->start();
                    }
                    LOG ("Start Done\n");
		            state = StatePlay;
                }
            break;

            case StatePlay:
				isDone = CurrentGame->update(ts.delta());

				if (isDone)
				{
					LOG ("Game Done\n");
					state = StateResults;
					Delay = 3;
					playSfx (CheersSound);
				}
				else
				{
					for (unsigned i = 0; i < gNumCubes; i++)
					{
						CurrentGameCube[i]->update(ts.delta());
					}
				}
            break;

            case StateResults:
                Delay -= float(ts.delta());

                if (Delay <= 0)
                {
					state = StateInit;
					LOG ("Results Done\n");
					
					int rand = randomGen.randint(0, 3);
					switch (rand)
					{
					    case 0:
						case 2:
						case 3:
						LOG ("Playing Flip It\n");
						CurrentGame = &flipItGame;
					    break;
						
					    case 1:
						LOG ("Playing Shake\n");
						CurrentGame = &shakeGame;
						break;
					} 
                }
            break;

        }

        System::paint();
        ts.next();
    }
}
开发者ID:runjumpdev,项目名称:SifteoGameJam,代码行数:96,代码来源:main.cpp


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