wall merging

This commit is contained in:
DarthMooMancer
2025-10-26 00:20:21 -04:00
parent b43f9972d7
commit 5e5f712a84
4 changed files with 58 additions and 30 deletions
+6 -1
View File
@@ -23,7 +23,7 @@ int main() {
sf::Vector2<float> size { TILESIZE / 2.0f, TILESIZE / 2.0f };
sf::Vector2<float> pos { TILESIZE, TILESIZE };
float acceleration { 1.0f };
float max_velocity_y { 20.0f };
float max_velocity_y { 15.0f };
float border_size { -1.0f };
float dash_distance { 20.0f };
sf::Vector2f velocity { 4.0f, 0 };
@@ -53,6 +53,8 @@ int main() {
wall_list[i][j] = new Entity { tile_data.size, tile_data.pos, tile_data.velocity, tile_data.border_size, sf::Color::Black };
}
merged_walls(wall_list);
for(auto[i, j] : std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
if(wall_list[i][j] == nullptr) continue;
wall_list[i][j]->rect.setPosition({ (j * tile_data.size.x), (i * tile_data.size.y) });
@@ -106,6 +108,9 @@ int main() {
// }
player.handle_gravity();
if(player.get_velocity().y > ((float)TILESIZE / 2)) {
player.set_velocity_y(TILESIZE / 2);
}
if(!player.get_vertical_bottom_collision(wall_list)) {
player.get_vertical_top_collision(wall_list);
}