void move(t_vector2d *player_pos, double stepx, double stepy, double way) { t_vector2d next_player_pos; next_player_pos = vector2d_add_scal(*player_pos, STEP * stepx * way, STEP * stepy * way); printf("next player position : "); print_vector(next_player_pos); printf("\n"); if (!wall_collision(player_pos, next_player_pos)) move(player_pos, stepx, stepy, way); else { printf("final player position : "); print_vector(*player_pos); printf("\n\n"); } }
/** * This is the main wrapper function for all other collision checking functions. * * @param[in,out] world A pointer to the world structure. * @param[in] entity The temporary position entity used for checking for collisions. * @param[in,out] temp The temporary position that will be applied later. * @param[out] entity_number The collision type of the entity that was hit (if any). * @param[out] tile_number The collision type of the tile that was hit (if any). * @param[out] hit_entity The identifier of the entity that was hit (if any). * * @designer Clark Allenby & Joshua Campbell * @author Clark Allenby */ void collision_system(World* world, unsigned int entity, PositionComponent* temp, unsigned int* entity_number, unsigned int* tile_number, unsigned int* hit_entity) { wall_collision(world, *temp, tile_number); entity_collision(world, entity, *temp, entity_number, hit_entity); }