remade the collision system
This commit is contained in:
+15
-19
@@ -69,12 +69,6 @@ main()
|
||||
running = false;
|
||||
window.close();
|
||||
}
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::C))
|
||||
{
|
||||
player.bounding_box->rect.setSize(
|
||||
{ total_distance(player.max_dash_acceleration),
|
||||
player.bounding_box->rect.getSize().y });
|
||||
}
|
||||
|
||||
if (map_manager.get_active() >= level_data.size())
|
||||
{
|
||||
@@ -89,10 +83,12 @@ main()
|
||||
scheduler.timers.at(1).reset();
|
||||
}
|
||||
|
||||
player.handle_movment(scheduler.timers.at(scheduler.pull("Dash")), map_manager.tilemap);
|
||||
// player.get_horizontal_collision(map_manager.tilemap);
|
||||
player.handle_movment(scheduler.timers.at(scheduler.pull("Dash")),
|
||||
map_manager.tilemap);
|
||||
std::cout << player.get_horizontal_collision(map_manager.tilemap) << "\n";
|
||||
|
||||
player.handle_gravity();
|
||||
player.get_vertical_collision(map_manager.tilemap);
|
||||
player.vertical_no_out_of_bounds();
|
||||
// if (player.get_velocity().y > ((float)TILESIZE / 2 - GRAVITY))
|
||||
// {
|
||||
@@ -108,20 +104,20 @@ main()
|
||||
// player.update_bounding_box();
|
||||
// // player.check_bounding_box(map_manager.tilemap);
|
||||
// }
|
||||
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||
if(map_manager.tilemap[i][j]) {
|
||||
std::cout << player.find_intersection(*map_manager.tilemap[i][j]);
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
// for (auto [i, j] :
|
||||
// rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS)))
|
||||
// {
|
||||
// if (map_manager.tilemap[i][j] == nullptr) continue;
|
||||
// if(player.find_intersection(*map_manager.tilemap[i][j]).x > 0) {
|
||||
// std::cout << player.find_intersection(*map_manager.tilemap[i][j]).x << "\n";
|
||||
// // running = false;
|
||||
// // window.close();
|
||||
// }
|
||||
// }
|
||||
|
||||
map_manager.draw(window);
|
||||
window.draw(player.rect);
|
||||
// if (player.bounding_box != nullptr)
|
||||
// {
|
||||
// window.draw(player.bounding_box->rect);
|
||||
// }
|
||||
// window.draw(text);
|
||||
window.draw(text);
|
||||
window.display();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user