Skip to content

Commit

Permalink
fighter screen: if docked, zoom out
Browse files Browse the repository at this point in the history
  • Loading branch information
Pithlit committed Jun 14, 2024
1 parent 169971d commit bded755
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/screens/crew1/singleFighterScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,29 @@ void SingleFighterScreen::onDraw(sp::RenderTarget& renderer)
{
if (my_spaceship)
{
camera_yaw = my_spaceship->getRotation();
camera_pitch = 0.0f;
auto position = my_spaceship->getPosition() + rotateVec2(glm::vec2(my_spaceship->getRadius(), 0), camera_yaw);
if (my_spaceship->docking_state == DS_Docked)
{
float target_camera_yaw = my_spaceship->getRotation();
float camera_ship_distance = 420.0f;
float camera_ship_height = 420.0f;

auto cameraPosition2D = my_spaceship->getPosition() + vec2FromAngle(target_camera_yaw) * -camera_ship_distance;
glm::vec3 targetCameraPosition(cameraPosition2D.x, cameraPosition2D.y, camera_ship_height);

camera_position.x = position.x;
camera_position.y = position.y;
camera_position.z = 0.0;
camera_position = camera_position * 0.9f + targetCameraPosition * 0.1f;
camera_yaw += angleDifference(camera_yaw, target_camera_yaw) * 0.1f;
camera_pitch += angleDifference(camera_pitch, 30.0f) * 0.1f;
}
else
{
camera_pitch = 0.0f;
camera_yaw = my_spaceship->getRotation();
auto position = my_spaceship->getPosition() + rotateVec2(glm::vec2(my_spaceship->getRadius(), 0), camera_yaw);

camera_position.x = position.x;
camera_position.y = position.y;
camera_position.z = 0.0;
}

energy_display->setValue(string(int(my_spaceship->energy_level)));
heading_display->setValue(string(my_spaceship->getHeading(), 1));
Expand Down

0 comments on commit bded755

Please sign in to comment.