remaking entire collsion system
This commit is contained in:
+26
-25
@@ -32,10 +32,6 @@ std::string assets = "/home/andrew/personal/Projects/CPP/engine/assets/";
|
||||
int
|
||||
main()
|
||||
{
|
||||
// float dist = total_distance(12);
|
||||
// std::cout << "Distance: " << dist << "\n";
|
||||
// float acc = distance_to_acceleration(total_distance(12));
|
||||
// std::cout << "Distance: " << acc << "\n";
|
||||
Scheduler scheduler;
|
||||
Manager map_manager;
|
||||
map_manager.load(level_data[BASE]);
|
||||
@@ -93,34 +89,39 @@ main()
|
||||
scheduler.timers.at(1).reset();
|
||||
}
|
||||
|
||||
player.handle_movment(scheduler.timers.at(scheduler.pull("Dash")));
|
||||
player.get_horizontal_collision(map_manager.tilemap);
|
||||
player.handle_movment(scheduler.timers.at(scheduler.pull("Dash")), map_manager.tilemap);
|
||||
// player.get_horizontal_collision(map_manager.tilemap);
|
||||
|
||||
player.handle_gravity();
|
||||
std::cout << "Vel: " << player.get_velocity().x << ", " << player.get_velocity().y
|
||||
<< "\n";
|
||||
if (player.get_velocity().y > ((float)TILESIZE / 2 - GRAVITY))
|
||||
{
|
||||
player.set_velocity_y((TILESIZE / 2) - GRAVITY);
|
||||
}
|
||||
player.vertical_no_out_of_bounds();
|
||||
// if (player.get_velocity().y > ((float)TILESIZE / 2 - GRAVITY))
|
||||
// {
|
||||
// player.set_velocity_y((TILESIZE / 2) - GRAVITY);
|
||||
// }
|
||||
|
||||
if (!player.get_vertical_bottom_collision(map_manager.tilemap))
|
||||
{
|
||||
player.get_vertical_top_collision(map_manager.tilemap);
|
||||
}
|
||||
if (player.bounding_box != nullptr)
|
||||
{
|
||||
player.update_bounding_box();
|
||||
player.check_bounding_box(map_manager.tilemap);
|
||||
// if (!player.get_vertical_bottom_collision(map_manager.tilemap))
|
||||
// {
|
||||
// player.get_vertical_top_collision(map_manager.tilemap);
|
||||
// }
|
||||
// if (player.bounding_box != nullptr)
|
||||
// {
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
map_manager.draw(window);
|
||||
window.draw(player.rect);
|
||||
if (player.bounding_box != nullptr)
|
||||
{
|
||||
window.draw(player.bounding_box->rect);
|
||||
}
|
||||
window.draw(text);
|
||||
// if (player.bounding_box != nullptr)
|
||||
// {
|
||||
// window.draw(player.bounding_box->rect);
|
||||
// }
|
||||
// window.draw(text);
|
||||
window.display();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user