fp: Move some structs to entity.h
This commit is contained in:
parent
d3444c84f1
commit
bff3fc759d
120
feely_pona.cpp
120
feely_pona.cpp
@ -204,7 +204,6 @@ void TELY_DLL_Init(void *user_data)
|
|||||||
|
|
||||||
// NOTE: Hero
|
// NOTE: Hero
|
||||||
{
|
{
|
||||||
TELY_AssetSpriteSheet *sheet = &game->terry_sprite_sheet;
|
|
||||||
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Terry");
|
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Terry");
|
||||||
entity->local_pos = Dqn_V2_InitNx2(1334, 396);
|
entity->local_pos = Dqn_V2_InitNx2(1334, 396);
|
||||||
entity->action_to_anim_mapping = game->terry_action_mappings;
|
entity->action_to_anim_mapping = game->terry_action_mappings;
|
||||||
@ -223,7 +222,7 @@ void TELY_DLL_Init(void *user_data)
|
|||||||
// NOTE: Merchant
|
// NOTE: Merchant
|
||||||
{
|
{
|
||||||
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Merchant");
|
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Merchant");
|
||||||
entity->type = FP_GameEntityType_Merchant;
|
entity->type = FP_EntityType_Merchant;
|
||||||
entity->local_pos = Dqn_V2_InitNx2(1000, 124);
|
entity->local_pos = Dqn_V2_InitNx2(1000, 124);
|
||||||
entity->local_hit_box_size = Dqn_V2_InitNx2(50, 50);
|
entity->local_hit_box_size = Dqn_V2_InitNx2(50, 50);
|
||||||
entity->size_scale = Dqn_V2_InitNx1(0.25f);
|
entity->size_scale = Dqn_V2_InitNx1(0.25f);
|
||||||
@ -248,7 +247,6 @@ void TELY_DLL_Init(void *user_data)
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t const base_width = right_wall_tile_pos.x - left_wall_top_tile.x;
|
|
||||||
Dqn_V2I const vert_wall_part_tile_size = Dqn_V2I_InitNx2(1, (vert_wall_tile_size.y / 2) - 2);
|
Dqn_V2I const vert_wall_part_tile_size = Dqn_V2I_InitNx2(1, (vert_wall_tile_size.y / 2) - 2);
|
||||||
FP_Game_EntityAddWallAtTile(game, DQN_STRING8("Base left-top wall"), left_wall_top_tile, vert_wall_part_tile_size);
|
FP_Game_EntityAddWallAtTile(game, DQN_STRING8("Base left-top wall"), left_wall_top_tile, vert_wall_part_tile_size);
|
||||||
|
|
||||||
@ -323,12 +321,12 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
FP_ActionToAnimationMapping result = {};
|
FP_ActionToAnimationMapping result = {};
|
||||||
|
|
||||||
switch (entity->type) {
|
switch (entity->type) {
|
||||||
case FP_GameEntityType_Terry: {
|
case FP_EntityType_Terry: {
|
||||||
FP_GameTerryState *state = DQN_CAST(FP_GameTerryState *)&action->state;
|
FP_EntityTerryState *state = DQN_CAST(FP_EntityTerryState *)&action->state;
|
||||||
if (*state == FP_GameTerryState_Nil)
|
if (*state == FP_EntityTerryState_Nil)
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Idle);
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_Idle) {
|
if (*state == FP_EntityTerryState_Idle) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_idle);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_idle);
|
||||||
|
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
@ -338,35 +336,35 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||||
switch (entity->direction) {
|
switch (entity->direction) {
|
||||||
case FP_GameDirection_Up: {
|
case FP_GameDirection_Up: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackUp);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackUp);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Left: {
|
case FP_GameDirection_Left: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackSide);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Right: {
|
case FP_GameDirection_Right: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackSide);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Down: {
|
case FP_GameDirection_Down: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackDown);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackDown);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
} else if (dir_vector.x || dir_vector.y) {
|
} else if (dir_vector.x || dir_vector.y) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Run);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_AttackSide) {
|
if (*state == FP_EntityTerryState_AttackSide) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_side);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_side);
|
||||||
action->flip_on_x = entity->direction == FP_GameDirection_Right;
|
action->flip_on_x = entity->direction == FP_GameDirection_Right;
|
||||||
|
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
||||||
} else if (action_has_finished) {
|
} else if (action_has_finished) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Idle);
|
||||||
action->flip_on_x = false;
|
action->flip_on_x = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +374,7 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||||
Dqn_f32 t01 = action->timer_s / action->end_at_s;
|
Dqn_f32 t01 = action->timer_s / action->end_at_s;
|
||||||
if (t01 > 0.5f)
|
if (t01 > 0.5f)
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackB);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackB);
|
||||||
else
|
else
|
||||||
action->flags |= FP_GameEntityActionFlag_Failed;
|
action->flags |= FP_GameEntityActionFlag_Failed;
|
||||||
}
|
}
|
||||||
@ -384,25 +382,25 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_AttackUp) {
|
if (*state == FP_EntityTerryState_AttackUp) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_up);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_up);
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
||||||
} else if (action_has_finished) {
|
} else if (action_has_finished) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_AttackDown) {
|
if (*state == FP_EntityTerryState_AttackDown) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_down);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_attack_down);
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
||||||
} else if (action_has_finished) {
|
} else if (action_has_finished) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_Run) {
|
if (*state == FP_EntityTerryState_Run) {
|
||||||
Dqn_String8 desired_action_name = {};
|
Dqn_String8 desired_action_name = {};
|
||||||
switch (entity->direction) {
|
switch (entity->direction) {
|
||||||
case FP_GameDirection_Up: desired_action_name = g_anim_names.terry_walk_up; break;
|
case FP_GameDirection_Up: desired_action_name = g_anim_names.terry_walk_up; break;
|
||||||
@ -417,24 +415,24 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_X)) {
|
||||||
switch (entity->direction) {
|
switch (entity->direction) {
|
||||||
case FP_GameDirection_Up: {
|
case FP_GameDirection_Up: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackUp);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackUp);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Left: {
|
case FP_GameDirection_Left: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackSide);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Right: {
|
case FP_GameDirection_Right: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackSide);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackSide);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Down: {
|
case FP_GameDirection_Down: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_AttackDown);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_AttackDown);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
} else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_LeftShift) ||
|
} else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_LeftShift) ||
|
||||||
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_A)) {
|
TELY_Platform_InputGamepadButtonCodeIsPressed(input, 0, TELY_PlatformInputGamepadButtonCode_A)) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Dash);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Dash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,11 +442,11 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!entity_has_velocity /*&& !has_collision*/) {
|
if (!entity_has_velocity /*&& !has_collision*/) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_Dash) {
|
if (*state == FP_EntityTerryState_Dash) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_right);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_walk_right);
|
||||||
|
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
@ -469,16 +467,16 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
} else if (action_has_finished) {
|
} else if (action_has_finished) {
|
||||||
if (entity_has_velocity) {
|
if (entity_has_velocity) {
|
||||||
// TODO(doyle): Not sure if this branch triggers properly.
|
// TODO(doyle): Not sure if this branch triggers properly.
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Run);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Run);
|
||||||
} else {
|
} else {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryState_Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameTerryState_AttackUp ||
|
if (*state == FP_EntityTerryState_AttackUp ||
|
||||||
*state == FP_GameTerryState_AttackDown ||
|
*state == FP_EntityTerryState_AttackDown ||
|
||||||
*state == FP_GameTerryState_AttackSide) {
|
*state == FP_EntityTerryState_AttackSide) {
|
||||||
entity->attack_box_size = entity->local_hit_box_size;
|
entity->attack_box_size = entity->local_hit_box_size;
|
||||||
|
|
||||||
// NOTE: Position the attack box
|
// NOTE: Position the attack box
|
||||||
@ -494,12 +492,12 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameEntityType_Smoochie: {
|
case FP_EntityType_Smoochie: {
|
||||||
FP_GameSmoochieState *state = DQN_CAST(FP_GameSmoochieState *)&action->state;
|
FP_EntitySmoochieState *state = DQN_CAST(FP_EntitySmoochieState *)&action->state;
|
||||||
if (*state == FP_GameSmoochieState_Nil)
|
if (*state == FP_EntitySmoochieState_Nil)
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_Idle);
|
||||||
|
|
||||||
if (*state == FP_GameSmoochieState_Idle) {
|
if (*state == FP_EntitySmoochieState_Idle) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_walk_down);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_walk_down);
|
||||||
|
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
@ -512,40 +510,40 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
case FP_GameDirection_Up: /*FALLTHRU*/
|
case FP_GameDirection_Up: /*FALLTHRU*/
|
||||||
case FP_GameDirection_Right: /*FALLTHRU*/
|
case FP_GameDirection_Right: /*FALLTHRU*/
|
||||||
case FP_GameDirection_Left: {
|
case FP_GameDirection_Left: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackSide);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_AttackSide);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Down: {
|
case FP_GameDirection_Down: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackDown);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_AttackDown);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
} else if (dir_vector.x || dir_vector.y) {
|
} else if (dir_vector.x || dir_vector.y) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Run);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_Run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameSmoochieState_AttackDown) {
|
if (*state == FP_EntitySmoochieState_AttackDown) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack_down);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack_down);
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
||||||
} else if (action_has_finished) {
|
} else if (action_has_finished) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameSmoochieState_AttackSide) {
|
if (*state == FP_EntitySmoochieState_AttackSide) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack_side);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.smoochie_attack_side);
|
||||||
action->flip_on_x = entity->direction == FP_GameDirection_Right;
|
action->flip_on_x = entity->direction == FP_GameDirection_Right;
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
FP_Game_EntityActionReset(action, result.anim.count * result.anim.seconds_per_frame, result);
|
||||||
} else if (action_has_finished) {
|
} else if (action_has_finished) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_Idle);
|
||||||
action->flip_on_x = false;
|
action->flip_on_x = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameSmoochieState_Run) {
|
if (*state == FP_EntitySmoochieState_Run) {
|
||||||
Dqn_String8 desired_action_name = {};
|
Dqn_String8 desired_action_name = {};
|
||||||
switch (entity->direction) {
|
switch (entity->direction) {
|
||||||
case FP_GameDirection_Up: desired_action_name = g_anim_names.smoochie_walk_up; break;
|
case FP_GameDirection_Up: desired_action_name = g_anim_names.smoochie_walk_up; break;
|
||||||
@ -563,11 +561,11 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
case FP_GameDirection_Up: /*FALLTHRU*/
|
case FP_GameDirection_Up: /*FALLTHRU*/
|
||||||
case FP_GameDirection_Right: /*FALLTHRU*/
|
case FP_GameDirection_Right: /*FALLTHRU*/
|
||||||
case FP_GameDirection_Left: {
|
case FP_GameDirection_Left: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackSide);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_AttackSide);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameDirection_Down: {
|
case FP_GameDirection_Down: {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_AttackDown);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_AttackDown);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -579,11 +577,11 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!entity_has_velocity /*&& !has_collision*/) {
|
if (!entity_has_velocity /*&& !has_collision*/) {
|
||||||
FP_Game_EntityActionSetState(action, FP_GameSmoochieState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntitySmoochieState_Idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*state == FP_GameSmoochieState_AttackSide || *state == FP_GameSmoochieState_AttackDown) {
|
if (*state == FP_EntitySmoochieState_AttackSide || *state == FP_EntitySmoochieState_AttackDown) {
|
||||||
entity->attack_box_size = entity->local_hit_box_size;
|
entity->attack_box_size = entity->local_hit_box_size;
|
||||||
// NOTE: Position the attack box
|
// NOTE: Position the attack box
|
||||||
if (entity->direction == FP_GameDirection_Left) {
|
if (entity->direction == FP_GameDirection_Left) {
|
||||||
@ -599,12 +597,12 @@ FP_ActionToAnimationMapping FP_EntityActionStateMachine(FP_Game *game, TELY_Plat
|
|||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameEntityType_Merchant: {
|
case FP_EntityType_Merchant: {
|
||||||
FP_GameTerryMerchantState *state = DQN_CAST(FP_GameTerryMerchantState *)&action->state;
|
FP_EntityTerryMerchantState *state = DQN_CAST(FP_EntityTerryMerchantState *)&action->state;
|
||||||
if (*state == FP_GameTerryMerchantState_Nil)
|
if (*state == FP_EntityTerryMerchantState_Nil)
|
||||||
FP_Game_EntityActionSetState(action, FP_GameTerryMerchantState_Idle);
|
FP_Game_EntityActionSetState(action, FP_EntityTerryMerchantState_Idle);
|
||||||
|
|
||||||
if (*state == FP_GameTerryMerchantState_Idle) {
|
if (*state == FP_EntityTerryMerchantState_Idle) {
|
||||||
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_merchant);
|
result = FP_Game_GetActionAnimMappingWithName(game, entity->handle, g_anim_names.terry_merchant);
|
||||||
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
if (action->flags & FP_GameEntityActionFlag_StateTransition) {
|
||||||
FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, result);
|
FP_Game_EntityActionReset(action, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, result);
|
||||||
@ -669,14 +667,14 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_Renderer *renderer,
|
|||||||
if (entity->flags & (FP_GameEntityFlag_MoveByKeyboard | FP_GameEntityFlag_MoveByGamepad)) {
|
if (entity->flags & (FP_GameEntityFlag_MoveByKeyboard | FP_GameEntityFlag_MoveByGamepad)) {
|
||||||
bool move_entity = false;
|
bool move_entity = false;
|
||||||
switch (entity->type) {
|
switch (entity->type) {
|
||||||
case FP_GameEntityType_Terry: {
|
case FP_EntityType_Terry: {
|
||||||
FP_GameTerryState *state = DQN_CAST(FP_GameTerryState *)&entity->action.state;
|
FP_EntityTerryState *state = DQN_CAST(FP_EntityTerryState *)&entity->action.state;
|
||||||
move_entity = *state == FP_GameTerryState_Run || *state == FP_GameTerryState_Idle;
|
move_entity = *state == FP_EntityTerryState_Run || *state == FP_EntityTerryState_Idle;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_GameEntityType_Smoochie: {
|
case FP_EntityType_Smoochie: {
|
||||||
FP_GameSmoochieState *state = DQN_CAST(FP_GameSmoochieState *)&entity->action.state;
|
FP_EntitySmoochieState *state = DQN_CAST(FP_EntitySmoochieState *)&entity->action.state;
|
||||||
move_entity = *state == FP_GameSmoochieState_Run || *state == FP_GameSmoochieState_Idle;
|
move_entity = *state == FP_EntitySmoochieState_Run || *state == FP_EntitySmoochieState_Idle;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
feely_pona_entity.h
Normal file
38
feely_pona_entity.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#if defined(__clang__)
|
||||||
|
#pragma once
|
||||||
|
#include "feely_pona_unity.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum FP_EntityType
|
||||||
|
{
|
||||||
|
FP_EntityType_Terry,
|
||||||
|
FP_EntityType_Smoochie,
|
||||||
|
FP_EntityType_Merchant,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum FP_EntityTerryState
|
||||||
|
{
|
||||||
|
FP_EntityTerryState_Nil,
|
||||||
|
FP_EntityTerryState_Idle,
|
||||||
|
FP_EntityTerryState_AttackUp,
|
||||||
|
FP_EntityTerryState_AttackDown,
|
||||||
|
FP_EntityTerryState_AttackSide,
|
||||||
|
FP_EntityTerryState_Run,
|
||||||
|
FP_EntityTerryState_Dash,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum FP_EntitySmoochieState
|
||||||
|
{
|
||||||
|
FP_EntitySmoochieState_Nil,
|
||||||
|
FP_EntitySmoochieState_Idle,
|
||||||
|
FP_EntitySmoochieState_AttackDown,
|
||||||
|
FP_EntitySmoochieState_AttackSide,
|
||||||
|
FP_EntitySmoochieState_AttackHeart,
|
||||||
|
FP_EntitySmoochieState_Run,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum FP_EntityTerryMerchantState
|
||||||
|
{
|
||||||
|
FP_EntityTerryMerchantState_Nil,
|
||||||
|
FP_EntityTerryMerchantState_Idle,
|
||||||
|
};
|
@ -668,7 +668,7 @@ static FP_GameEntityHandle FP_Game_EntityAddWallAtTile(FP_Game *game, Dqn_String
|
|||||||
static FP_GameEntityHandle FP_Game_EntityAddMob(FP_Game *game, Dqn_V2 pos)
|
static FP_GameEntityHandle FP_Game_EntityAddMob(FP_Game *game, Dqn_V2 pos)
|
||||||
{
|
{
|
||||||
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Mob");
|
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, "Mob");
|
||||||
entity->type = FP_GameEntityType_Smoochie;
|
entity->type = FP_EntityType_Smoochie;
|
||||||
entity->local_pos = pos;
|
entity->local_pos = pos;
|
||||||
entity->size_scale = Dqn_V2_InitNx1(.25f);
|
entity->size_scale = Dqn_V2_InitNx1(.25f);
|
||||||
entity->action_to_anim_mapping = game->smoochie_action_mappings;
|
entity->action_to_anim_mapping = game->smoochie_action_mappings;
|
||||||
|
@ -83,40 +83,6 @@ enum FP_GameDirection
|
|||||||
FP_GameDirection_Right,
|
FP_GameDirection_Right,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FP_GameEntityType
|
|
||||||
{
|
|
||||||
FP_GameEntityType_Terry,
|
|
||||||
FP_GameEntityType_Smoochie,
|
|
||||||
FP_GameEntityType_Merchant,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FP_GameTerryState
|
|
||||||
{
|
|
||||||
FP_GameTerryState_Nil,
|
|
||||||
FP_GameTerryState_Idle,
|
|
||||||
FP_GameTerryState_AttackUp,
|
|
||||||
FP_GameTerryState_AttackDown,
|
|
||||||
FP_GameTerryState_AttackSide,
|
|
||||||
FP_GameTerryState_Run,
|
|
||||||
FP_GameTerryState_Dash,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FP_GameSmoochieState
|
|
||||||
{
|
|
||||||
FP_GameSmoochieState_Nil,
|
|
||||||
FP_GameSmoochieState_Idle,
|
|
||||||
FP_GameSmoochieState_AttackDown,
|
|
||||||
FP_GameSmoochieState_AttackSide,
|
|
||||||
FP_GameSmoochieState_AttackHeart,
|
|
||||||
FP_GameSmoochieState_Run,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FP_GameTerryMerchantState
|
|
||||||
{
|
|
||||||
FP_GameTerryMerchantState_Nil,
|
|
||||||
FP_GameTerryMerchantState_Idle,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FP_GameEntity
|
struct FP_GameEntity
|
||||||
{
|
{
|
||||||
FP_GameEntity *next;
|
FP_GameEntity *next;
|
||||||
@ -125,7 +91,7 @@ struct FP_GameEntity
|
|||||||
FP_GameEntity *last_child;
|
FP_GameEntity *last_child;
|
||||||
FP_GameEntity *parent;
|
FP_GameEntity *parent;
|
||||||
|
|
||||||
FP_GameEntityType type;
|
FP_EntityType type;
|
||||||
Dqn_String8 name;
|
Dqn_String8 name;
|
||||||
FP_GameEntityHandle handle;
|
FP_GameEntityHandle handle;
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
|
|||||||
#include "External/tely/tely_rfui.cpp"
|
#include "External/tely/tely_rfui.cpp"
|
||||||
|
|
||||||
// NOTE: feely_pona ================================================================================
|
// NOTE: feely_pona ================================================================================
|
||||||
|
#include "feely_pona_entity.h"
|
||||||
#include "feely_pona_game.h"
|
#include "feely_pona_game.h"
|
||||||
#include "feely_pona.h"
|
#include "feely_pona.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user