Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Iji::Move()
- {
- //is Iji moving?
- m_IsMoving = (m_CanMove && ((GAME_ENGINE->IsKeyboardKeyDown(m_KeysArr[0]) && m_Direction == -1) ||
- (GAME_ENGINE->IsKeyboardKeyDown(m_KeysArr[1]) && m_Direction == 1)));
- if (m_IsMoving && m_IsOnGround && m_ActionState != ActionState::WALKING)
- {
- if (m_ActionState != ActionState::STANDING)
- SoundManager::SoundPlay(String("Resources/Audio/Iji/snd_iji_land.wav"), SoundManager::SoundType::SFX);
- m_ActionState = ActionState::WALKING;
- }
- //press left
- if (GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[0]) && m_CanMove)
- m_Direction = -1;
- //press right
- if (GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[1]) && m_CanMove)
- m_Direction = 1;
- //move/release left
- if (m_Direction == -1)
- {
- if (GAME_ENGINE->IsKeyboardKeyDown(m_KeysArr[0]) &&
- m_CanMove)
- m_ActPtr->SetLinearVelocity(DOUBLE2(-m_HorSpeed, m_ActPtr->GetLinearVelocity().y));
- if (GAME_ENGINE->IsKeyboardKeyDown(m_KeysArr[0]) == false &&
- m_IsOnGround &&
- (m_ActionState == ActionState::WALKING ||
- m_ActionState == ActionState::FALLING ||
- m_ActionState == ActionState::JUMPING))
- {
- if (m_ActionState != ActionState::WALKING)
- SoundManager::SoundPlay(String("Resources/Audio/Iji/snd_iji_land.wav"), SoundManager::SoundType::SFX);
- m_ActPtr->SetLinearVelocity(DOUBLE2(0, m_ActPtr->GetLinearVelocity().y));
- m_ActionState = ActionState::STANDING;
- }
- }
- //move/release right
- if (m_Direction == 1)
- {
- if (GAME_ENGINE->IsKeyboardKeyDown(m_KeysArr[1]) &&
- m_CanMove)
- m_ActPtr->SetLinearVelocity(DOUBLE2(m_HorSpeed, m_ActPtr->GetLinearVelocity().y));
- if(GAME_ENGINE->IsKeyboardKeyDown(m_KeysArr[1]) == false &&
- m_IsOnGround &&
- (m_ActionState == ActionState::WALKING ||
- m_ActionState == ActionState::FALLING ||
- m_ActionState == ActionState::JUMPING))
- {
- if (m_ActionState != ActionState::WALKING)
- SoundManager::SoundPlay(String("Resources/Audio/Iji/snd_iji_land.wav"), SoundManager::SoundType::SFX);
- m_ActPtr->SetLinearVelocity(DOUBLE2(0, m_ActPtr->GetLinearVelocity().y));
- m_ActionState = ActionState::STANDING;
- }
- }
- if (m_IsOnGround)
- {
- m_FallTime = 0;
- //jump
- if (GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[2]) && m_CanMove &&
- (m_ElevatorPtr ==nullptr || m_ElevatorPtr->CanGoUp()==false))
- {
- m_ActPtr->SetLinearVelocity(DOUBLE2(m_ActPtr->GetLinearVelocity().x, -m_JumpSpeed));
- m_JumpTime = 10;
- m_ActionState = ActionState::JUMPING;
- if (rand()%6==0)
- SoundManager::SoundPlay(String("Resources/Audio/Iji/snd_iji_jump.wav"), SoundManager::SoundType::SFX);
- }
- }
- if (m_ActionState != ActionState::JUMPING && m_ActionState!=ActionState::ELEVATOR && !m_IsOnGround)
- ++m_FallTime;
- if (m_FallTime>10 && m_ActionState!=ActionState::FALLING && m_ActionState!=ActionState::FLYING)
- m_ActionState = ActionState::FALLING;
- //thrown onto ground
- if (m_ActionState == ActionState::FLYING && m_IsOnGround)
- m_ActionState = ActionState::LYING;
- //get up from ground
- if (m_ActionState == ActionState::LYING &&
- m_Dead==false && (
- GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[0]) ||
- GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[1]) ||
- GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[2]) ||
- GAME_ENGINE->IsKeyboardKeyPressed(m_KeysArr[3])))
- m_ActionState = ActionState::GETUP;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement