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())) { 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 = !IsPassable(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::CheckEventTriggers() { if (trigger == RPG::EventPage::Trigger_auto_start) { Start(); } else if (trigger == RPG::EventPage::Trigger_collision) { CheckEventTriggerTouch(GetX(),GetY()); } }
void Game_Event::CheckEventTriggers() { if (trigger == RPG::EventPage::Trigger_auto_start) { if (Player::GetFrames() == frame_count_at_last_auto_start_check) { // Delay the start to the next frame because the event was enabled // by an event with an higher ID than this event. return; } Start(); } else if (trigger == RPG::EventPage::Trigger_collision) { CheckEventTriggerTouch(GetX(),GetY()); } }
void Game_Character::MoveUp() { if (turn_enabled) TurnUp(); if (IsPassable(x, y, RPG::EventPage::Direction_up)) { TurnUp(); y -= 1; //IncreaseSteps(); move_failed = false; } else { CheckEventTriggerTouch(x, y - 1); move_failed = true; } }
void Game_Character::MoveRight() { if (turn_enabled) TurnRight(); if (IsPassable(x, y, RPG::EventPage::Direction_right)) { TurnRight(); x += 1; //IncreaseSteps(); move_failed = false; } else { CheckEventTriggerTouch(x + 1, y); move_failed = true; } }
void Game_Character::MoveUp() { if (!IsDirectionFixed()) TurnUp(); if (jumping) { jump_plus_y--; return; } if (IsPassable(GetX(), GetY(), RPG::EventPage::Direction_up)) { SetY(GetY() - 1); BeginMove(); stop_count = 0; move_failed = false; } else { CheckEventTriggerTouch(GetX(), GetY() - 1); move_failed = true; } }