Compare commits

..

No commits in common. "5a0c02b81a23e9ca40ea4ca82bc2b848fccac8fc" and "ededdb488b5e424bbc9002792dbeebf5ca76233b" have entirely different histories.

2 changed files with 15 additions and 12 deletions

View File

@ -114,6 +114,17 @@ static bool check_collision_and_move(
offset.y = overlap.y;
}
}
else if (other_solid == ONE_WAY)
{
// One way collision is a bit special
if (
p_ct->prev_position.y + p_bbox->size.y < other_pos->y
&& ent->position.y + p_bbox->size.y >= other_pos->y
)
{
offset.y = other_pos->y - (ent->position.y + p_bbox->size.y);
}
}
ent->position = Vector2Add(ent->position, offset);
}
else if (overlap_mode == 2)
@ -772,21 +783,12 @@ void tile_collision_system(Scene_t* scene)
(tile_idx / tilemap.width) * tilemap.tile_size
+ tilemap.tiles[tile_idx].offset.y; // Precision loss is intentional
SolidType_t solid = tilemap.tiles[tile_idx].solid;
// One way collision is a bit special
if (solid == ONE_WAY)
{
solid = (
p_ctransform->prev_position.y + p_bbox->size.y <= other.y
&& p_ent->position.y + p_bbox->size.y > other.y
) ? SOLID : NOT_SOLID;
}
check_collision_and_move(
&tilemap, p_ent,
&other,
//tilemap.tiles[tile_idx].size,
(Vector2){tilemap.tile_size, tilemap.tile_size},
solid
tilemap.tiles[tile_idx].solid
);
}
@ -819,6 +821,7 @@ void tile_collision_system(Scene_t* scene)
}
}
}
}
}

View File

@ -294,7 +294,7 @@ void change_a_tile(TileGrid_t* tilemap, unsigned int tile_idx, TileType_t new_ty
}
}
if (tile_idx >= tilemap->width)
if (tile_idx - tilemap->width >= 0)
{
tilemap->tiles[tile_idx].connectivity |= (tilemap->tiles[tile_idx - tilemap->width].tile_type == SOLID_TILE) ? (1 << UP_BIT) : 0;
if (new_type == SOLID_TILE)