fp: Cap the camera to the map, redo clinger assets

This commit is contained in:
doyle 2023-09-30 22:27:25 +10:00
parent 8301bdb86c
commit 015ae9d82b
25 changed files with 78 additions and 49 deletions

BIN
Data/Textures/clinger_resized_25%.png (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Data/Textures/map_resized_25%.png (Stored with Git LFS)

Binary file not shown.

BIN
Data/Textures/map_resized_25%/map.png (Stored with Git LFS)

Binary file not shown.

2
External/tely vendored

@ -1 +1 @@
Subproject commit dd059e0f2308e2e2fce05f214f43a8d86ceb443f
Subproject commit 72fcc90d2e8f5737568d334f3ce97d6353e91f9c

View File

@ -291,18 +291,20 @@ void TELY_DLL_Init(void *user_data)
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Map");
entity->type = FP_EntityType_Map;
entity->sprite_height.meters = 41.9f;
entity->local_pos = Dqn_V2_InitNx2(-533, 516);
entity->local_pos = {};
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
entity->local_hit_box_size = sprite_rect_scaled;
FP_Entity_AddDebugEditorFlags(game, entity->handle);
game->map = entity;
}
// NOTE: Hero
{
FP_GameEntityHandle terry = FP_Entity_CreateTerry(game, Dqn_V2_InitNx2(1334, 396), "Terry");
FP_GameEntityHandle terry = FP_Entity_CreateTerry(game, Dqn_V2_InitNx2(1434, 11), "Terry");
game->clicked_entity = terry;
game->player = terry;
}
@ -959,6 +961,9 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
dir_vector.y *= 0.7071067811865475244f;
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_Escape))
game->clicked_entity = {};
if (game->clicked_entity.id) {
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_Delete))
FP_Game_DeleteEntity(game, game->clicked_entity);
@ -1010,6 +1015,9 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
entity->direction = dir_vector.x > 0.f ? FP_GameDirection_Right : FP_GameDirection_Left;
else if (dir_vector.y)
entity->direction = dir_vector.y > 0.f ? FP_GameDirection_Down : FP_GameDirection_Up;
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_Space))
acceleration_meters_per_s *= 2.5f;
}
}
} else {
@ -1231,7 +1239,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
Dqn_Log_InfoF("Height: %.1f", entity->sprite_height.meters);
}
game->camera.world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle) - Dqn_V2_InitV2I(platform->core.window_size) * .5f;
if (entity->flags & FP_GameEntityFlag_CameraTracking)
game->camera.world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle) - Dqn_V2_InitV2I(platform->core.window_size) * .5f;
}
}
@ -1367,6 +1376,20 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
}
}
}
{
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->map_sprite_sheet, g_anim_names.map);
Dqn_Rect sprite_rect = game->map_sprite_sheet.rects.data[sprite_anim->index];
const Dqn_usize target_width = 1800;
const Dqn_usize target_height = 1046;
game->camera.world_pos.x = DQN_MIN(game->camera.world_pos.x, game->map->local_hit_box_size.w * +0.5f - target_width);
game->camera.world_pos.x = DQN_MAX(game->camera.world_pos.x, game->map->local_hit_box_size.w * -0.5f);
game->camera.world_pos.y = DQN_MAX(game->camera.world_pos.y, game->map->local_hit_box_size.h * -0.5f);
game->camera.world_pos.y = DQN_MIN(game->camera.world_pos.y, game->map->local_hit_box_size.h * +0.5f - target_height);
}
Dqn_Profiler_EndZone(update_zone);
}
@ -1612,7 +1635,7 @@ void TELY_DLL_FrameUpdate(void *user_data)
TELY_RFui_FrameSetup(rfui, &platform->frame_arena);
TELY_RFui_PushFont(rfui, game->jetbrains_mono_font);
TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4);
TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_BLACK_MIDNIGHT_V4);
// =============================================================================================
@ -1711,9 +1734,10 @@ void TELY_DLL_FrameUpdate(void *user_data)
1000.0 / input->delta_ms,
input->frame_counter,
input->timer_s);
}
// NOTE: Profiler
// NOTE: Other
{
TELY_RFuiResult profiler_layout = TELY_RFui_Column(rfui, DQN_STRING8("Profiler Bar"));
profiler_layout.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute;
@ -1724,6 +1748,8 @@ void TELY_DLL_FrameUpdate(void *user_data)
TELY_RFui_PushParent(rfui, profiler_layout.widget);
DQN_DEFER { TELY_RFui_PopParent(rfui); };
TELY_RFui_TextF(rfui, "Camera: %.1f, %.1f", game->camera.world_pos.x, game->camera.world_pos.y);
Dqn_ProfilerAnchor *anchors = Dqn_Profiler_AnchorBuffer(Dqn_ProfilerAnchorBuffer_Back);
for (size_t anchor_index = 1; anchor_index < DQN_PROFILER_ANCHOR_BUFFER_SIZE; anchor_index++) {
Dqn_ProfilerAnchor const *anchor = anchors + anchor_index;

View File

@ -140,12 +140,13 @@ static FP_GameEntityHandle FP_Entity_CreateTerry(FP_Game *game, Dqn_V2 pos, DQN_
entity->type = FP_EntityType_Terry;
entity->local_pos = pos;
entity->base_acceleration_per_s.meters = 8.f;
entity->base_acceleration_per_s.meters = 16.f;
entity->sprite_height.meters = 1.8f;
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game, 0.5f, entity->sprite_height.meters * .6f);
FP_Entity_AddDebugEditorFlags(game, result);
entity->flags |= FP_GameEntityFlag_NonTraversable;
entity->flags |= FP_GameEntityFlag_Attackable;
entity->flags |= FP_GameEntityFlag_CameraTracking;
return result;
}

View File

@ -19,6 +19,7 @@ enum FP_GameEntityFlag
FP_GameEntityFlag_RespondsToClubTerry = 1 << 11,
FP_GameEntityFlag_PartyingAtClubTerry = 1 << 12,
FP_GameEntityFlag_ExperiencedClubTerry = 1 << 13,
FP_GameEntityFlag_CameraTracking = 1 << 14,
};
enum FP_GameShapeType
@ -232,6 +233,7 @@ struct FP_Game
FP_GameEntity *root_entity;
FP_GameEntity *entity_free_list;
FP_GameEntity *map;
FP_GameEntityHandle player;