Exemplo n.º 1
0
void Predator::update(){
	this->setZOrder(MapManager::getInstance()->_mapHeight - this->getPositionY());

	updateAI();

	if (!isMoving() \
		&& GameManager::getInstance()->_gameState == (int)GameManager::GameState::IN_THE_GAME)
	{

		switch (_moveTrigger){
		case CHARACTER_DIRECTION_DOWN:
			if (moveDown() == true){
				_state = (int)State::WALK;
				_moveSpeed = PREDATOR_WALK_MOVE_SPEED;
			}	
			break;
		case CHARACTER_DIRECTION_LEFT:
			if (moveLeft() == true){
				_state = (int)State::WALK;
				_moveSpeed = PREDATOR_WALK_MOVE_SPEED;
			}
			break;
		case CHARACTER_DIRECTION_RIGHT:			
			if (moveRight() == true){
				_state = (int)State::WALK;
				_moveSpeed = PREDATOR_WALK_MOVE_SPEED;
			}			
			break;
		case CHARACTER_DIRECTION_UP:
			if (moveUp() == true){
				_state = (int)State::WALK;
				_moveSpeed = PREDATOR_WALK_MOVE_SPEED;
			}
			break;
		default:
			break;
		}
	}

	if (isMoving())
	{
		updateMove();

	}
	//若本帧不作任何移动
	else
	{
		if (_state == (int)State::WALK)
		{
			_state = (int)State::STOP;
		}
	}

	updateFrame();
}
Exemplo n.º 2
0
void Antimony::step()
{
	timer.catchTime(TIMER_FRAME_GLOBAL);
	delta = timer.getDelta();
	double fstep = delta * worldSpeed;

	cpuUsage.GetUsage(0);

	if (GetForegroundWindow() == window_main.hWnd && mouse.isExclusive())
	{
		mouse.acquire(false);
	}
	else
	{
		mouse.release(false);
		/*SetCursor(arrow);
		SetClassLong(window_main.hWnd, GCL_HCURSOR, (DWORD)arrow);*/
	}

	updateGameState();

	if (ifGameState(GAMESTATE_INGAME))									// In-game (non-paused, non-menu etc.)
	{
		if (devConsole.isOpen())
		{
			player.lock();
			camera_main.lock();
		}
		else
		{
			player.unlock();
			camera_main.unlock();
		}

		updateAI(fstep);														// update AI/scripts etc. (TBI)
		updateWorld(fstep);														// update moving objects, triggers etc. (TBI)
		player.update(delta, m_objectsCollisions);
		updatePlayerControls(&keys, &controller[0], fstep);						// update player inputs
		updatePhysics(fstep);													// btWorld step
		updateCameraControls(&mouse, &keys, &controller[0], fstep);				// update camera (--> mat_view)
	}
	else if (ifGameState(GAMESTATE_PAUSED) && devConsole.isClosed())		// Game is paused
	{
		camera_main.unlock();

		updateCameraControls(&mouse, &keys, &controller[0], fstep);				// update camera (--> mat_view)
	}

	prepareFrame();														// prepare the frame for rendering
}
Exemplo n.º 3
0
void Player::update(Game& game, Level& level)
{
	processQueuedActions(game);

	if (hasValidState() == false)
	{
		return;
	}
	if (useAI == true)
	{
		updateAI(level);
	}

	if (playerStatus != PlayerStatus::Dead &&
		LifeNow() <= 0)
	{
		playerStatus = PlayerStatus::Dead;
		playSound(dieSound);
	}

	switch (playerStatus)
	{
	default:
	case PlayerStatus::Stand:
		updateAnimation(game);
		break;
	case PlayerStatus::Walk:
		updateWalk(game, level);
		break;
	case PlayerStatus::Attack:
		updateAttack(game, level);
		break;
	case PlayerStatus::Dead:
		updateDead(game, level);
		break;
	}

	updateHover(game, level);
}
Exemplo n.º 4
0
void EnemyBossGreen::update()
{
	updateAI();
}