Compare commits
No commits in common. "395e8dc58a1e4cb50e8652e3619f77b2c635051c" and "46bf26a7c3102f424b0da3efc7186fae85377d22" have entirely different histories.
395e8dc58a
...
46bf26a7c3
@ -480,7 +480,7 @@ static void FP_PlayReset(FP_Game *game, TELY_Platform *platform)
|
||||
FP_Entity_CreateBillboard(game, Dqn_V2_InitNx2(1898, 771), FP_EntityBillboardState_Strafe, "Strafe Billboard");
|
||||
|
||||
// NOTE: Camera ================================================================================
|
||||
play->camera.world_pos = {};
|
||||
play->camera.world_pos = base_mid_p - Dqn_V2_InitV2I(platform->core.window_size * .5f);
|
||||
play->camera.scale = Dqn_V2_InitNx1(1);
|
||||
play->camera.size = Dqn_V2_InitNx2(1826, 1046);
|
||||
}
|
||||
@ -1996,7 +1996,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
|
||||
if (entity->flags & FP_GameEntityFlag_CameraTracking) {
|
||||
FP_GameCamera *camera = &game->play.camera;
|
||||
camera->world_pos_target = FP_Game_CalcEntityWorldPos(game, entity->handle) * camera->scale;
|
||||
camera->world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle) * camera->scale;
|
||||
}
|
||||
|
||||
FP_GamePlaceableBuilding placeable_building = PLACEABLE_BUILDINGS[game->play.build_mode_building_index];
|
||||
@ -2290,12 +2290,11 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Camera ================================================================================
|
||||
FP_GamePlay *play = &game->play;
|
||||
FP_GameCamera *camera = &play->camera;
|
||||
if (!FP_Game_IsNilEntityHandle(game, game->play.clicked_entity)) {
|
||||
Dqn_V2 window_size = Dqn_V2_InitV2I(platform->core.window_size);
|
||||
FP_GamePlay *play = &game->play;
|
||||
|
||||
FP_GameCamera *camera = &play->camera;
|
||||
camera->scale = window_size / camera->size;
|
||||
Dqn_V2 camera_size_screen = camera->size * camera->scale;
|
||||
|
||||
@ -2303,13 +2302,12 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
Dqn_V2 map_screen_size = map_world_size * camera->scale;
|
||||
Dqn_V2 half_map_screen_size = map_screen_size * .5f;
|
||||
|
||||
camera->world_pos_target.x = DQN_MIN(camera->world_pos_target.x, half_map_screen_size.w - (camera_size_screen.w * .5f));
|
||||
camera->world_pos_target.x = DQN_MAX(camera->world_pos_target.x, -half_map_screen_size.w + (camera_size_screen.w * .5f));
|
||||
camera->world_pos_target.y = DQN_MAX(camera->world_pos_target.y, -half_map_screen_size.h + (camera_size_screen.h * .5f));
|
||||
camera->world_pos_target.y = DQN_MIN(camera->world_pos_target.y, half_map_screen_size.h - (camera_size_screen.h * .5f));
|
||||
camera->world_pos.x = DQN_MIN(camera->world_pos.x, half_map_screen_size.w - (camera_size_screen.w * .5f));
|
||||
camera->world_pos.x = DQN_MAX(camera->world_pos.x, -half_map_screen_size.w + (camera_size_screen.w * .5f));
|
||||
camera->world_pos.y = DQN_MAX(camera->world_pos.y, -half_map_screen_size.h + (camera_size_screen.h * .5f));
|
||||
camera->world_pos.y = DQN_MIN(camera->world_pos.y, half_map_screen_size.h - (camera_size_screen.h * .5f));
|
||||
}
|
||||
|
||||
camera->world_pos += (camera->world_pos_target - camera->world_pos) * (5.f * DQN_CAST(Dqn_f32)input->delta_s);
|
||||
Dqn_Profiler_EndZone(update_zone);
|
||||
}
|
||||
|
||||
@ -3602,8 +3600,8 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
||||
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F9 %s god mode", game->play.god_mode ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
|
||||
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F10 %s noclip", player->flags & FP_GameEntityFlag_NoClip ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
|
||||
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F11 Building inventory +1"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
|
||||
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F12 %s by enemies", player->faction == FP_GameEntityFaction_Nil ? "Attacked" : "Ignored"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
|
||||
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " 1 %s HUD", game->play.debug_hide_hud ? "Show" : "Hide"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
|
||||
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " 2 %s by enemies", player->faction == FP_GameEntityFaction_Nil ? "Attacked" : "Ignored"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
|
||||
TELY_Render_PopFont(renderer);
|
||||
TELY_Render_PopColourV4(renderer);
|
||||
|
||||
@ -3658,15 +3656,14 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
||||
player->inventory.kennels += 1;
|
||||
}
|
||||
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1))
|
||||
game->play.debug_hide_hud = !game->play.debug_hide_hud;
|
||||
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_2)) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F12)) {
|
||||
player->faction = player->faction == FP_GameEntityFaction_Nil
|
||||
? FP_GameEntityFaction_Friendly
|
||||
: FP_GameEntityFaction_Nil;
|
||||
}
|
||||
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1))
|
||||
game->play.debug_hide_hud = !game->play.debug_hide_hud;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,6 @@ struct FP_GameCamera
|
||||
{
|
||||
Dqn_V2 size;
|
||||
Dqn_V2 world_pos;
|
||||
Dqn_V2 world_pos_target;
|
||||
Dqn_f32 rotate_rads;
|
||||
Dqn_V2 scale;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user