fp: Add collide rules in move entity

This commit is contained in:
doyle 2023-09-29 15:58:03 +10:00
parent 4842bd32f9
commit 2aa3a9568b
2 changed files with 27 additions and 1 deletions

View File

@ -159,6 +159,31 @@ static void FP_Game_MoveEntity(FP_Game *game, FP_GameEntityHandle entity_handle,
if ((collider->flags & FP_GameEntityFlag_NonTraversable) == 0)
continue;
bool entity_collides_with_collider = true;
switch (entity->type) {
case FP_EntityType_Nil: {
} break;
case FP_EntityType_Terry: {
} break;
case FP_EntityType_Smoochie: {
if (collider->type == FP_EntityType_Smoochie || collider->type == FP_EntityType_Clinger)
entity_collides_with_collider = false;
} break;
case FP_EntityType_Clinger: {
if (collider->type == FP_EntityType_Smoochie || collider->type == FP_EntityType_Clinger)
entity_collides_with_collider = false;
} break;
case FP_EntityType_Merchant: {
} break;
}
if (!entity_collides_with_collider)
continue;
// NOTE: Sweep collider with half the radius of the source entity
Dqn_Rect collider_world_hit_box = FP_Game_CalcEntityWorldHitBox(game, collider->handle);
Dqn_Rect swept_collider_world_hit_box = collider_world_hit_box;
@ -1197,7 +1222,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
else
attack_dir_vector.x = -1.f;
Dqn_V2 attack_acceleration_meters_per_s = attack_dir_vector * 20.f;
Dqn_V2 attack_acceleration_meters_per_s = attack_dir_vector * 60.f;
FP_Game_MoveEntity(game, defender->handle, attack_acceleration_meters_per_s);
}
}

View File

@ -10,6 +10,7 @@ enum FP_EntityType
FP_EntityType_Smoochie,
FP_EntityType_Merchant,
FP_EntityType_Clinger,
FP_EntityType_Count,
};
enum FP_EntityTerryState