fp: Integrate map
This commit is contained in:
parent
d48db90783
commit
eb90d7dbfa
BIN
Data/Textures/map_resized_25%.png
(Stored with Git LFS)
Normal file
BIN
Data/Textures/map_resized_25%.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Data/Textures/map_resized_25%.txt
(Stored with Git LFS)
Normal file
BIN
Data/Textures/map_resized_25%.txt
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Data/Textures/map_resized_25%/map.png
(Stored with Git LFS)
Normal file
BIN
Data/Textures/map_resized_25%/map.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Data/Textures/sprite_spec.txt
(Stored with Git LFS)
BIN
Data/Textures/sprite_spec.txt
(Stored with Git LFS)
Binary file not shown.
@ -15,3 +15,4 @@ if not exist "%sprite_packer%" (
|
||||
%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\smoochie_resized_25%% || exit /b 1
|
||||
%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\clinger_resized_25%% || exit /b 1
|
||||
%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\club_terry_resized_25%% || exit /b 1
|
||||
%sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\map_resized_25%% || exit /b 1
|
||||
|
@ -147,6 +147,7 @@ static void FP_Game_MoveEntity(FP_Game *game, FP_GameEntityHandle entity_handle,
|
||||
case FP_EntityType_Merchant: /*FALLTRHU*/
|
||||
case FP_EntityType_Count: break;
|
||||
case FP_EntityType_ClubTerry: break;
|
||||
case FP_EntityType_Map: break;
|
||||
}
|
||||
|
||||
if (!entity_collides_with_collider)
|
||||
@ -275,12 +276,30 @@ void TELY_DLL_Init(void *user_data)
|
||||
game->smoochie_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("smoochie_resized_25%"));
|
||||
game->clinger_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("clinger_resized_25%"));
|
||||
game->club_terry_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("club_terry_resized_25%"));
|
||||
game->map_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("map_resized_25%"));
|
||||
}
|
||||
|
||||
game->entities = Dqn_VArray_Init<FP_GameEntity>(&platform->arena, 1024 * 8);
|
||||
game->root_entity = Dqn_VArray_Make(&game->entities, Dqn_ZeroMem_No);
|
||||
Dqn_FArray_Add(&game->parent_entity_stack, game->root_entity->handle);
|
||||
|
||||
// NOTE: Map
|
||||
{
|
||||
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];
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// NOTE: Hero
|
||||
{
|
||||
FP_GameEntityHandle terry = FP_Entity_CreateTerry(game, Dqn_V2_InitNx2(1334, 396), "Terry");
|
||||
@ -878,20 +897,30 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_PlatformInput *input, FP_Ga
|
||||
|
||||
} break;
|
||||
|
||||
case FP_EntityType_Map: {
|
||||
FP_EntityMapState *state = DQN_CAST(FP_EntityMapState *) & action->state;
|
||||
TELY_AssetSpriteSheet *sheet = &game->map_sprite_sheet;
|
||||
|
||||
switch (*state) {
|
||||
case FP_EntityMapState_Nil: {
|
||||
action->next_state = FP_EntityMapState_Idle;
|
||||
} break;
|
||||
|
||||
case FP_EntityMapState_Idle: {
|
||||
if (entering_new_state) {
|
||||
TELY_AssetAnimatedSprite sprite = TELY_Asset_MakeAnimatedSprite(sheet, g_anim_names.map, TELY_AssetFlip_No);
|
||||
uint64_t duration_ms = FP_GAME_ENTITY_ACTION_INFINITE_TIMER;
|
||||
FP_Game_EntityActionReset(game, entity->handle, duration_ms, sprite);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case FP_EntityType_Nil: break;
|
||||
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
|
||||
}
|
||||
}
|
||||
|
||||
bool FindTurnSide(Dqn_f32 current, Dqn_f32 target)
|
||||
{
|
||||
Dqn_f32 diff = target - current;
|
||||
if(diff < 0)
|
||||
diff += (DQN_PI * 2.f);
|
||||
if(diff > DQN_PI)
|
||||
return false; // left turn
|
||||
else
|
||||
return true; // right turn
|
||||
}
|
||||
}
|
||||
|
||||
void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input)
|
||||
@ -970,6 +999,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
case FP_EntityType_Nil: break;
|
||||
case FP_EntityType_ClubTerry: break;
|
||||
case FP_EntityType_Count: break;
|
||||
case FP_EntityType_Map: break;
|
||||
}
|
||||
|
||||
if (move_entity) {
|
||||
@ -1163,6 +1193,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
|
||||
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
|
||||
case FP_EntityType_ClubTerry: break;
|
||||
case FP_EntityType_Map: break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1187,6 +1218,17 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
|
||||
// NOTE: Tick the state machine
|
||||
FP_EntityActionStateMachine(game, input, entity, dir_vector);
|
||||
|
||||
if (game->clicked_entity == entity->handle) {
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F1)) {
|
||||
entity->sprite_height.meters += 1;
|
||||
Dqn_Log_InfoF("Height: %.1f", entity->sprite_height.meters);
|
||||
}
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) {
|
||||
entity->sprite_height.meters -= 1;
|
||||
Dqn_Log_InfoF("Height: %.1f", entity->sprite_height.meters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Update entity =========================================================================
|
||||
@ -1293,6 +1335,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
case FP_EntityType_Merchant: /*FALLTRHU*/
|
||||
case FP_EntityType_Count: break;
|
||||
case FP_EntityType_ClubTerry: break;
|
||||
case FP_EntityType_Map: break;
|
||||
}
|
||||
|
||||
if (!permit_attack)
|
||||
|
@ -49,8 +49,10 @@ struct FP_GlobalAnimations
|
||||
Dqn_String8 clinger_walk_up = DQN_STRING8("clinger_walk_up");
|
||||
Dqn_String8 clinger_walk_down = DQN_STRING8("clinger_walk_down");
|
||||
|
||||
Dqn_String8 club_terry_alive = DQN_STRING8("club_terry_alive");
|
||||
Dqn_String8 club_terry_dark = DQN_STRING8("club_terry_dark");
|
||||
Dqn_String8 club_terry_alive = DQN_STRING8("club_terry_alive");
|
||||
Dqn_String8 club_terry_dark = DQN_STRING8("club_terry_dark");
|
||||
|
||||
Dqn_String8 map = DQN_STRING8("map");
|
||||
}
|
||||
g_anim_names;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
enum FP_EntityType
|
||||
{
|
||||
FP_EntityType_Nil,
|
||||
FP_EntityType_Map,
|
||||
FP_EntityType_Terry,
|
||||
FP_EntityType_Smoochie,
|
||||
FP_EntityType_Merchant,
|
||||
@ -55,3 +56,9 @@ enum FP_EntityClubTerryState
|
||||
FP_EntityClubTerryState_Idle,
|
||||
FP_EntityClubTerryState_PartyTime,
|
||||
};
|
||||
|
||||
enum FP_EntityMapState
|
||||
{
|
||||
FP_EntityMapState_Nil,
|
||||
FP_EntityMapState_Idle,
|
||||
};
|
||||
|
@ -220,6 +220,7 @@ struct FP_Game
|
||||
TELY_AssetSpriteSheet terry_merchant_sprite_sheet;
|
||||
TELY_AssetSpriteSheet clinger_sprite_sheet;
|
||||
TELY_AssetSpriteSheet club_terry_sprite_sheet;
|
||||
TELY_AssetSpriteSheet map_sprite_sheet;
|
||||
|
||||
FP_GameEntity *root_entity;
|
||||
FP_GameEntity *entity_free_list;
|
||||
|
Loading…
Reference in New Issue
Block a user