fp: Orient sprite in direction of velocity

This commit is contained in:
2023-09-27 00:09:14 +10:00
parent a9fba6f01d
commit ffb2ec3ea3
2 changed files with 12 additions and 5 deletions
+10 -1
View File
@@ -470,6 +470,10 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_PlatformInput *input, FP_Ga
action->next_state = FP_EntitySmoochieState_Run;
}
}
if (entity_has_velocity) {
action->next_state = FP_EntitySmoochieState_Run;
}
} break;
case FP_EntitySmoochieState_AttackDown: {
@@ -681,6 +685,11 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
entity->direction = dir_vector.y > 0.f ? FP_GameDirection_Down : FP_GameDirection_Up;
}
}
} else {
if (entity->velocity.x)
entity->direction = entity->velocity.x > 0.f ? FP_GameDirection_Right : FP_GameDirection_Left;
else if (entity->velocity.y)
entity->direction = entity->velocity.y > 0.f ? FP_GameDirection_Down : FP_GameDirection_Up;
}
// NOTE: Determine AI movement =============================================================
@@ -743,7 +752,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
// NOTE: We haven't arrived yet, calculate an acceleration vector to the waypoint
if (dist_to_waypoint_sq > DQN_SQUARED(arrival_threshold)) {
Dqn_V2 entity_to_waypoint_norm = Dqn_V2_Normalise(entity_to_waypoint);
acceleration_meters_per_s = entity_to_waypoint_norm * 4.f;
acceleration_meters_per_s = entity_to_waypoint_norm * 2.f;
break;
}