Merge branch 'main' into profiling

main
En Yi 2024-09-02 22:45:47 +08:00
commit f6847f1ffd
1 changed files with 21 additions and 19 deletions

View File

@ -761,12 +761,12 @@ void tile_collision_system(Scene_t* scene)
tile_y1 = (tile_y1 < 0) ? 0 : tile_y1;
tile_y2 = (tile_y2 >= tilemap.height) ? tilemap.height - 1 : tile_y2;
uint8_t collide_side = 0;
for (unsigned int tile_y = tile_y1; tile_y <= tile_y2; tile_y++)
{
for (unsigned int tile_x = tile_x1; tile_x <= tile_x2; tile_x++)
{
unsigned int tile_idx = tile_y * tilemap.width + tile_x;
uint8_t collide_side = 0;
if(tilemap.tiles[tile_idx].tile_type != EMPTY_TILE)
{
Vector2 other;
@ -787,7 +787,7 @@ void tile_collision_system(Scene_t* scene)
&& p_ent->position.y + p_bbox->size.y > other.y
) ? SOLID : NOT_SOLID;
}
collide_side = check_collision_and_move(
collide_side |= check_collision_and_move(
&tilemap, p_ent,
&other,
(Vector2){tilemap.tile_size, tilemap.tile_size},
@ -815,7 +815,7 @@ void tile_collision_system(Scene_t* scene)
{
solid = NOT_SOLID;
}
collide_side = check_collision_and_move(
collide_side |= check_collision_and_move(
&tilemap, p_ent,
&p_other_ent->position, p_other_bbox->size,
solid
@ -823,6 +823,10 @@ void tile_collision_system(Scene_t* scene)
}
}
}
}
if (collide_side & (1<<3))
{
if (p_ctransform->velocity.x < 0) p_ctransform->velocity.x = 0;
@ -840,8 +844,6 @@ void tile_collision_system(Scene_t* scene)
if (p_ctransform->velocity.y > 0) p_ctransform->velocity.y = 0;
}
}
}
float decimal;
float fractional = modff(p_ent->position.x, &decimal);
if (fractional > 0.99)