Compare commits
No commits in common. "62de96609b023c8fef2f744b2abd10960ff22b75" and "5cbacf8516afe8ee553022d716d2cdbd2dd3fb57" have entirely different histories.
62de96609b
...
5cbacf8516
9
main.c
9
main.c
|
@ -62,11 +62,6 @@ int main(void)
|
||||||
// appear in the polling of raylib
|
// appear in the polling of raylib
|
||||||
Scene_t* curr_scene = engine.scenes[engine.curr_scene];
|
Scene_t* curr_scene = engine.scenes[engine.curr_scene];
|
||||||
|
|
||||||
if (curr_scene->state == SCENE_ENDED && engine.curr_scene == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
process_inputs(&engine, curr_scene);
|
process_inputs(&engine, curr_scene);
|
||||||
|
|
||||||
update_scene(curr_scene);
|
update_scene(curr_scene);
|
||||||
|
@ -79,6 +74,10 @@ int main(void)
|
||||||
sc_queue_clear(&key_buffer);
|
sc_queue_clear(&key_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curr_scene->state == SCENE_ENDED && engine.curr_scene == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free_sandbox_scene(&sandbox_scene);
|
free_sandbox_scene(&sandbox_scene);
|
||||||
free_game_scene(&level_scene);
|
free_game_scene(&level_scene);
|
||||||
|
|
|
@ -45,11 +45,10 @@ static bool check_collision_and_move(
|
||||||
// If there is collision, use previous overlap to determine direction
|
// If there is collision, use previous overlap to determine direction
|
||||||
find_AABB_overlap(p_ct->prev_position, p_bbox->size, *other_pos, other_bbox, &prev_overlap);
|
find_AABB_overlap(p_ct->prev_position, p_bbox->size, *other_pos, other_bbox, &prev_overlap);
|
||||||
|
|
||||||
// Resolve collision via moving player by the overlap amount only if other is solid
|
// Store collision event here
|
||||||
// also check for empty to prevent creating new collision. Not fool-proof, but good enough
|
// Check collision on x or y axis
|
||||||
|
// Encode key and value, -ve is left and up, +ve is right and down
|
||||||
Vector2 offset = {0, 0};
|
Vector2 offset = {0, 0};
|
||||||
if (other_solid == SOLID)
|
|
||||||
{
|
|
||||||
if (fabs(prev_overlap.y) > fabs(prev_overlap.x))
|
if (fabs(prev_overlap.y) > fabs(prev_overlap.x))
|
||||||
{
|
{
|
||||||
offset.x = overlap.x;
|
offset.x = overlap.x;
|
||||||
|
@ -66,20 +65,27 @@ static bool check_collision_and_move(
|
||||||
{
|
{
|
||||||
offset.y = overlap.y;
|
offset.y = overlap.y;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (other_solid == ONE_WAY)
|
// Resolve collision via moving player by the overlap amount only if other is solid
|
||||||
{
|
// also check for empty to prevent creating new collision. Not fool-proof, but good enough
|
||||||
// One way collision is a bit special
|
//if (other_solid && !check_collision_at(ent_idx, p_ct->position, sz, tilemap, offset, p_manager))
|
||||||
if (
|
if ( other_solid == SOLID
|
||||||
p_ct->prev_position.y + p_bbox->size.y - 1 < other_pos->y
|
|| (
|
||||||
&& p_ct->position.y + p_bbox->size.y - 1 >= other_pos->y
|
other_solid == ONE_WAY && offset.y < 0
|
||||||
|
&& (p_ct->prev_position.y + p_bbox->size.y - 1 < other_pos->y))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
offset.y = other_pos->y - (p_ct->position.y + p_bbox->size.y);
|
//if (!check_collision_offset(ent, p_ct->position, p_bbox->size, tilemap, offset))
|
||||||
}
|
{
|
||||||
}
|
|
||||||
p_ct->position = Vector2Add(p_ct->position, offset);
|
p_ct->position = Vector2Add(p_ct->position, offset);
|
||||||
}
|
}
|
||||||
|
//else
|
||||||
|
{
|
||||||
|
|
||||||
|
//*other_pos = Vector2Subtract(*other_pos, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (overlap_mode == 2)
|
else if (overlap_mode == 2)
|
||||||
{
|
{
|
||||||
if ( other_solid != SOLID ) goto collision_end;
|
if ( other_solid != SOLID ) goto collision_end;
|
||||||
|
|
Loading…
Reference in New Issue