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(); } } }
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(); } } }
void Game_Character::TurnUp() { SetDirection(RPG::EventPage::Direction_up); move_failed = false; if (!IsSpinning()) { stop_count = pow(2.0, 8 - GetMoveFrequency()); } }
void Game_Character::Move(int dir) { int dx = (dir == Right || dir == UpRight || dir == DownRight) - (dir == Left || dir == DownLeft || dir == UpLeft); int dy = (dir == Down || dir == DownRight || dir == DownLeft) - (dir == Up || dir == UpRight || dir == UpLeft); SetDirection(dir); if (!(IsDirectionFixed() || IsFacingLocked() || IsSpinning())) { if (dir > 3) // Diagonal SetSpriteDirection(GetSpriteDirection() % 2 ? -dx + 2 : dy + 1); else SetSpriteDirection(dir); } if (jumping) { jump_plus_x += dx; jump_plus_y += dy; return; } move_failed = !MakeWay(GetX(), GetY(), dir); if (move_failed) { if (!CheckEventTriggerTouch(Game_Map::RoundX(GetX() + dx), Game_Map::RoundY(GetY() + dy))) return; } else { SetX(Game_Map::RoundX(GetX() + dx)); SetY(Game_Map::RoundY(GetY() + dy)); remaining_step = SCREEN_TILE_WIDTH; BeginMove(); } stop_count = 0; max_stop_count = (GetMoveFrequency() > 7) ? 0 : pow(2.0, 9 - GetMoveFrequency()); }
void Game_Event::SetDirection(int new_direction) { if (new_direction != -1) { data.direction = new_direction; if (!IsSpinning()) { SetPrelockDirection(new_direction); } } }
void Character::UpdateItSelf( float dTime ) { // 가속 if ( IsAccelerating() ) { if ( timeGetTime() - GetAccelerationStartTime() > ACCELERATION_TIME ) { // 가속 끝났다 SetIsAccelerating( false ); SetAcceleration( ZERO_VECTOR3 ); } } if ( !m_CharacterClass->IsAlive() ) { //printf_s( "player %d is dead \n", m_CharacterId ); return; } m_Matrix = GetTransform()->MatrixTransform(); if ( IsSpinning() ) { AddSpinTime( dTime ); // 회전축을 기준으로 물체를 회전시킵니다. D3DXMATRIXA16 spinTransform; D3DXVECTOR3 tmpSpinAxis = GetSpinAxis(); float tmpSpinAngle = GetSpinAngularVelocity(); D3DXMatrixRotationAxis( &spinTransform, &tmpSpinAxis, tmpSpinAngle * GetSpinTime() ); // D3DXMatrixMultiply( &m_Matrix, &m_Matrix, &spinTransform ); D3DXMatrixMultiply( &m_Matrix, &spinTransform, &m_Matrix ); } D3DXVECTOR3 tmpVec3 = GetTransform()->GetPosition(); D3DXVECTOR3 tmpVel = GetVelocity(); Physics::CalcCurrentPosition( &tmpVec3, &tmpVel, GetAcceleration(), dTime, GetSpeedConstant() ); // 최대 이동거리 제한 float currentDistanceFromOrigin = D3DXVec3Length( &tmpVec3 ); if ( currentDistanceFromOrigin > MAX_DISTANCE_FROM_ORIGIN ) m_CharacterClass->SetOxygen( 0.0f ); // 최대 속도 제한 float currentSpeed = D3DXVec3Length( &tmpVel ); if ( currentSpeed > MAX_PLAYER_SPEED ) { D3DXVec3Normalize( &tmpVel, &tmpVel ); tmpVel *= MAX_PLAYER_SPEED; } GetTransform()->SetPosition( tmpVec3 ); SetVelocity( tmpVel ); // 산소량 감소등의 작업 처리 GetClassComponent()->Update( dTime ); }
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; } }
int Game_Character::GetSteppingSpeed() const { int move_speed = GetMoveSpeed(); if (IsSpinning()) { // 24, 16, 12, 8, 6, 4 return (move_speed < 4) ? 48 / (move_speed + 1) : 24 / (move_speed - 1); } else if (IsMoving()) { // 12, 10, 8, 6, 5, 4 return (move_speed < 4) ? 60 / (move_speed + 4) : 30 / (move_speed + 1); } else { // 16, 12, 10, 8, 7, 6 return (move_speed < 2) ? 16 : 60 / (move_speed + 3); } }
void Game_Character::UpdateMove() { int distance = ((SCREEN_TILE_WIDTH / 128) << GetMoveSpeed()); if (GetY() * SCREEN_TILE_WIDTH > real_y) real_y = min(real_y + distance, GetY() * SCREEN_TILE_WIDTH); if (GetX() * SCREEN_TILE_WIDTH < real_x) real_x = max(real_x - distance, GetX() * SCREEN_TILE_WIDTH); if (GetX() * SCREEN_TILE_WIDTH > real_x) real_x = min(real_x + distance, GetX() * SCREEN_TILE_WIDTH); if (GetY() * SCREEN_TILE_WIDTH < real_y) real_y = max(real_y - distance, GetY() * SCREEN_TILE_WIDTH); anime_count += (IsSpinning() ? 1.0 : (animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation) ? 1.5 : 0); }