コード例 #1
0
void Game_Character::Update() {
	if (IsJumping()) {
		UpdateJump();
		if (IsSpinning())
			anime_count++;
	} else if (IsMoving()) {
		remaining_step -= 1 << (1 + GetMoveSpeed());
		if (IsSpinning() || (animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation))
			anime_count++;
	} else {
		stop_count++;
		if (IsSpinning() || IsContinuous() || pattern != original_pattern)
			anime_count++;
	}

	if (anime_count >= GetSteppingSpeed()) {
		if (IsSpinning()) {
			SetSpriteDirection((GetSpriteDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}

	if (wait_count > 0) {
		wait_count -= 1;
		return;
	}

	if (stop_count >= max_stop_count) {
		if (IsMoveRouteOverwritten()) {
			MoveTypeCustom();
		} else {
			// Only events
			UpdateSelfMovement();
		}
	}
}
コード例 #2
0
ファイル: game_character.cpp プロジェクト: Ancurio/Player
void Game_Character::Update() {
	if (IsJumping()) {
		UpdateJump();
		anime_count += (IsSpinning() ? 1.0 : 0);
	} else if (IsContinuous() || IsSpinning()) {
		UpdateMove();
		UpdateStop();
	} else {
		if (IsMoving()) {
			UpdateMove();
		} else {
			UpdateStop();
		}
	}

	if (anime_count > 36.0/(GetMoveSpeed()+1)) {
		if (IsSpinning()) {
			SetPrelockDirection((GetPrelockDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}

	if (wait_count > 0) {
		wait_count -= 1;
		return;
	}

	if (stop_count >= ((GetMoveFrequency() > 7) ? 0 : pow(2.0, 9 - GetMoveFrequency()))) {
		if (IsMoveRouteOverwritten()) {
			MoveTypeCustom();
		} else if (Game_Message::GetContinueEvents() || !Game_Message::message_waiting) {
			UpdateSelfMovement();
		}
	}
}
コード例 #3
0
ファイル: game_character.cpp プロジェクト: KitoHo/Player
void Game_Character::UpdateSprite() {
	if (IsJumping()) {
		UpdateJump();
		if (IsSpinning())
			anime_count++;
	} else if (IsMoving()) {
		remaining_step -= min(1 << (1 + GetMoveSpeed()), remaining_step);
		if (IsSpinning() || (animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation))
			anime_count++;
	} else {
		stop_count++;
		if ((walk_animation && (IsSpinning() || IsContinuous())) || pattern != original_pattern)
			anime_count++;
	}

	if (anime_count >= GetSteppingSpeed()) {
		if (IsSpinning()) {
			SetSpriteDirection((GetSpriteDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}
}
コード例 #4
0
ファイル: TPCamera.cpp プロジェクト: ElIgnis/Alpha-AI
/********************************************************************************
Update the camera
********************************************************************************/
void TPCamera::Update(double dt)
{
	// WASD movement
	if (myKeys['w'] == true)
	{
		Walk(dt);
	}
	else
	{
		MoveVel_W = 0.0f;
	}
	if (myKeys['s'] == true)
	{
		Walk(-dt);
	}
	else
	{
		MoveVel_S = 0.0f;
	}
	if (myKeys['a'] == true)
	{
		Strafe(-dt);
	}
	else
	{
		MoveVel_A = 0.0f;
	}
	if (myKeys['d'] == true)
	{
		Strafe(dt);
	}
	else
	{
		MoveVel_D = 0.0f;
	}

	// Rotation
	if (myKeys[VK_UP] == true)
	{
		LookUp(dt);
	}
	if (myKeys[VK_DOWN] == true)
	{
		LookUp(-dt);
	}
	if (myKeys[VK_LEFT] == true)
	{
		TurnLeft(-dt);
	}
	if (myKeys[VK_RIGHT] == true)
	{
		TurnRight(dt);
	}

	// Jump
	if (myKeys[32] == true)
	{
		Jump(dt);
		myKeys[32] = false;
	}
	UpdateJump(dt);

	//Update the camera direction based on mouse move
	// left-right rotate
	/*if (Application::camera_yaw != 0)
		Yaw(dt);
	if (Application::camera_pitch != 0)
		Pitch(dt);

	if (Application::IsKeyPressed('R'))
	{
		Reset();
	}*/
}
コード例 #5
0
ファイル: FPcamera.cpp プロジェクト: Chongjx/Framework
void FPcamera::Update(double dt, float heightOffset)
{
	if(myKeys['w'])
	{
		if(myKeys['z'])
		{
			if (!m_bJumping)
			{
				Run(dt, heightOffset);
			}
			else
			{
				Walk(dt, heightOffset);
			}
			myKeys['z'] = false;
		}
		else
		{
			Walk(dt, heightOffset);
		}
		myKeys['w'] = false;
	}

	if(myKeys['s'])
	{
		if(myKeys['z'])
		{
			Run(-dt, heightOffset);
			myKeys['z'] = false;
		}
		else
		{
			Walk(-dt, heightOffset);
		}
		myKeys['s'] = false;
	}

	if(myKeys['a'])
	{
		Strafe(-dt, heightOffset);
		myKeys['a'] = false;
	}

	if(myKeys['d'])
	{
		Strafe(dt, heightOffset);
		myKeys['d'] = false;
	}

	if(myKeys['q'])
	{
		moveUp(dt, 5.f);
		myKeys['q'] = false;
	}

	if(myKeys['e'])
	{
		moveDown(dt, 5.f);
		myKeys['e'] = false;
	}

	if(myKeys[32])
	{
		Jump(dt);
		myKeys[32] = false;
	}

	if(myKeys['c'])
	{
		m_bCrouching = true;
		Crouch(dt, heightOffset);
		myKeys['c'] = false;
	}

	else
	{
		m_bCrouching = false;
		Crouch(-dt, heightOffset);
	}

	if(m_bRecoil)
	{
		static float timer = 0.f;

		lookUp(dt, 20.f);
		timer += (float)dt;

		if (timer >= 0.1f)
		{
			m_bRecoil = false;
			timer = 0.f;
		}
	}

	else if (!m_bRecoil && recoil > 0.f)
	{
		lookDown(dt, 20.f);
	}

	UpdateJump(dt, heightOffset);

	if(Application::camera_pitch != 0)
	{
		Pitch(dt);
	}
	if(Application::camera_yaw != 0)
	{
		Yaw(dt);
	}

	if(myKeys['r'])
	{
		Reset();
		myKeys['r'] = false;
	}
}