Added lerp with time in physics system.
This commit is contained in:
parent
c4646d67f4
commit
4e17c05c69
|
|
@ -1 +1 @@
|
|||
Subproject commit 6bfa68db05dafd773860bcea000f0c3fcba0176a
|
||||
Subproject commit 6ce19277e54e0c56be105d8edac118aa3f41ba67
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
goto failure; \
|
||||
} while (0);
|
||||
|
||||
#else
|
||||
#else
|
||||
#define debug_printf(...)
|
||||
|
||||
#define return_failure_int return EXIT_FAILURE;
|
||||
|
|
|
|||
|
|
@ -52,14 +52,13 @@ int physics_system_update(component_t *component)
|
|||
transform_component_data_t *transform_component_data = system_data->transform_component->data;
|
||||
hitbox_component_data_t *hitbox_component_data = system_data->hitbox_component->data;
|
||||
|
||||
system_data->velocity.x = lerp(system_data->velocity.x, system_data->target_velocity.x, system_data->smoothing_factor);
|
||||
system_data->velocity.y = lerp(system_data->velocity.y, system_data->target_velocity.y, system_data->smoothing_factor);
|
||||
|
||||
system_data->velocity.x = lerp_time(system_data->velocity.x, system_data->target_velocity.x * system_data->speed, system_data->smoothing_factor, game.delta_time_ms);
|
||||
system_data->velocity.y = lerp_time(system_data->velocity.y, system_data->target_velocity.y * system_data->speed, system_data->smoothing_factor, game.delta_time_ms);
|
||||
if(hitbox_component_data->activated)
|
||||
if(linked_list_for_each(&game.entity_manager.entities, action_detect_solve_entities_collision, component)) return EXIT_FAILURE;
|
||||
|
||||
transform_component_data->bounds.x += system_data->velocity.x * system_data->speed * (float)game.delta_time_ms / 1000.0f;
|
||||
transform_component_data->bounds.y += system_data->velocity.y * system_data->speed * (float)game.delta_time_ms / 1000.0f;
|
||||
transform_component_data->bounds.x += system_data->velocity.x * (float)game.delta_time_ms / 1000.0f;
|
||||
transform_component_data->bounds.y += system_data->velocity.y * (float)game.delta_time_ms / 1000.0f;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,14 @@ int game_init(void)
|
|||
};
|
||||
}
|
||||
|
||||
if(!entity_new_component(player_entity, PHYSICS_SYSTEM)) return_failure_int;
|
||||
{
|
||||
component_t *physics_component = entity_new_component(player_entity, PHYSICS_SYSTEM);
|
||||
if(!physics_component) return_failure_int;
|
||||
|
||||
physics_system_data_t *physics_system_data = physics_component->data;
|
||||
|
||||
physics_system_data->smoothing_factor = 0.0005;
|
||||
}
|
||||
|
||||
if(!entity_new_component(player_entity, PLAYER_SYSTEM)) return_failure_int;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue