diff --git a/Data/Textures/map_resized_25%.png b/Data/Textures/map_resized_25%.png new file mode 100644 index 0000000..06e426d --- /dev/null +++ b/Data/Textures/map_resized_25%.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0be7c733e8ca2173b0a1925dcca382565e1d335cdda8ec734c81820e953e096a +size 782126 diff --git a/Data/Textures/map_resized_25%.txt b/Data/Textures/map_resized_25%.txt new file mode 100644 index 0000000..4cf4b61 --- /dev/null +++ b/Data/Textures/map_resized_25%.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db56f93561ee9306af4abccae37aa0db95b3657d7178c869c6c50f8a93a8231c +size 57 diff --git a/Data/Textures/map_resized_25%/map.png b/Data/Textures/map_resized_25%/map.png new file mode 100644 index 0000000..ec01eff --- /dev/null +++ b/Data/Textures/map_resized_25%/map.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71dd040308a744e8d9f942b0a88c54f9259ce040575fe46be68d0c568157d414 +size 427872 diff --git a/Data/Textures/sprite_spec.txt b/Data/Textures/sprite_spec.txt index 075d539..1837e08 100644 --- a/Data/Textures/sprite_spec.txt +++ b/Data/Textures/sprite_spec.txt @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1023cacbcc52e050db9675912e1d0bdaa4ac78f3bb4ecc1c3b4f7c15f7368933 -size 520 +oid sha256:87e41f86d79fb3b93da6eaf9931c11f597631414dfa5863d6b98a38bb2cff73e +size 529 diff --git a/build_assets.bat b/build_assets.bat index 14c7dae..5b4037b 100644 --- a/build_assets.bat +++ b/build_assets.bat @@ -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 diff --git a/feely_pona.cpp b/feely_pona.cpp index c838304..8371ed3 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -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(&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) diff --git a/feely_pona.h b/feely_pona.h index 04179fb..ec9b824 100644 --- a/feely_pona.h +++ b/feely_pona.h @@ -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; diff --git a/feely_pona_entity.h b/feely_pona_entity.h index 865c4dd..2fa1b9e 100644 --- a/feely_pona_entity.h +++ b/feely_pona_entity.h @@ -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, +}; diff --git a/feely_pona_game.h b/feely_pona_game.h index 70ea6a5..76bd5ad 100644 --- a/feely_pona_game.h +++ b/feely_pona_game.h @@ -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;