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


C++ Wall::setChangesColor方法代码示例

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


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

示例1: update

BOOL Game::update()
{
	BOOL updateObjects = FALSE;
	BOOL checkForWinning = FALSE;
	BOOL checkForLosing = FALSE;
	BOOL checkCollisions = FALSE;
	BOOL stopMovement = TRUE;

	switch (itsCurrentState)
	{
		case GAMESTATE_PREGAME :
			// since the pregame section is so different, we will call our own method
			pregameUpdate();
			break;
		case GAMESTATE_INPROGRESS :
			updateObjects = TRUE;
			checkForWinning = TRUE;
			checkForLosing = TRUE;
			checkCollisions = TRUE;
			stopMovement = FALSE;
			break;
		case GAMESTATE_WON :
		{
			updateObjects = TRUE;
			Room *room = itsPlayer->getRoom();
			// we need to change the walls a color for that ending flashiness
			if (itsLastTickTime - itsWinTime >= theWinAnimationLength)
			{	
				for (UINT i=0;i<room->getWalls()->length();i++)
				{
					Wall *wall = (Wall *)(room->getWalls()->elementAt(i));
					wall->setChangesColor(FALSE);
				}
			}
			else
			{
				// since the player will be holding the chalice, we can tell
				// the walls to change colors, and they will change to the color
				// of the chalice, which will make them appear to animate
				for (UINT i=0;i<room->getWalls()->length();i++)
				{
					Wall *wall = (Wall *)(room->getWalls()->elementAt(i));
					wall->setChangesColor(TRUE,1);
				}
			}
			// hack to put the player in the right place for the ending
			itsPlayer->setX(Game::theScreenHeight-64);
			itsPlayer->setY(Game::theScreenWidth/2-16);
		}
		break;
		case GAMESTATE_LOST :
			updateObjects = TRUE;
			stopMovement = FALSE;
			break;
		case GAMESTATE_PAUSED :
			stopMovement = FALSE;
			break;
	}

	theEventDispatcher.update(itsLastTickTime);


	if (updateObjects)
	{
		SimpleArray *objects = NULL;
		if (itsWorld != NULL)
		objects = itsWorld->getObjects();
		for (UINT i=0;i<objects->length();i++)
		{
			((GameObject *)(objects->elementAt(i)))->update(itsLastTickTime);
			if (stopMovement)
			{
				((GameObject *)(objects->elementAt(i)))->stopMoving(itsLastTickTime);
			}
		}
		for (i=0;i<itsWorld->getRooms()->length();i++)
		{
			((Room *)(itsWorld->getRooms()->elementAt(i)))->checkForObjectsLeaving();
		}
	}
	if (checkForWinning && gameWon())
	{
		itsNewStateRequest.itsNewState = GAMESTATE_WON;
		itsNewStateRequest.isActiveRequest = TRUE;
	}
	if (checkForLosing && gameLost())
	{
		itsNewStateRequest.itsNewState = GAMESTATE_LOST;
		itsNewStateRequest.isActiveRequest = TRUE;
	}
	if (checkCollisions)
		return checkForCollisions();
	else
		return TRUE;
}
开发者ID:davetron5000,项目名称:adventureclone,代码行数:95,代码来源:Game.cpp


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