APPLE sucks and their libc libraries are old as fuck so c++23 things are not available like linux. Added MAC support so i can develop
This commit is contained in:
+34
-21
@@ -4,7 +4,12 @@
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
#ifdef __APPLE__
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/cartesian_product.hpp>
|
||||
#else
|
||||
#include <ranges>
|
||||
#endif
|
||||
|
||||
Entity::Entity(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, sf::Color inside_color, sf::Color border_color) {
|
||||
rect.setSize(size);
|
||||
@@ -106,7 +111,11 @@ void Player::vertical_no_out_of_bounds(Entity &base) {
|
||||
}
|
||||
|
||||
bool Player::get_horizontal_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
||||
#ifdef __APPLE__
|
||||
for(auto [i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
||||
#else
|
||||
for(auto [i, j] : std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
||||
#endif
|
||||
if(wall_list[i][j] == nullptr) continue;
|
||||
auto collision = wall_list[i][j]->find_intersection(*this);
|
||||
if(collision == CollisionDir::None) continue;
|
||||
@@ -121,33 +130,37 @@ bool Player::get_horizontal_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
||||
}
|
||||
|
||||
bool Player::get_vertical_top_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
||||
for(int i : std::views::iota(0, MAX_ROWS)) {
|
||||
for(int j : std::views::iota(0, MAX_COLS)) {
|
||||
if(wall_list[i][j] == nullptr) continue;
|
||||
auto collision = find_intersection(*wall_list[i][j]);
|
||||
if(collision == CollisionDir::None) continue;
|
||||
if(collision == CollisionDir::Top) {
|
||||
rect.setPosition({ rect.getPosition().x, wall_list[i][j]->rect.getSize().y + wall_list[i][j]->rect.getPosition().y + rect.getOutlineThickness()});
|
||||
set_velocity_y(0);
|
||||
return true;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
for(auto [i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
||||
#else
|
||||
for(auto [i, j] : std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
||||
#endif
|
||||
if(wall_list[i][j] == nullptr) continue;
|
||||
auto collision = find_intersection(*wall_list[i][j]);
|
||||
if(collision == CollisionDir::None) continue;
|
||||
if(collision == CollisionDir::Top) {
|
||||
rect.setPosition({ rect.getPosition().x, wall_list[i][j]->rect.getSize().y + wall_list[i][j]->rect.getPosition().y + rect.getOutlineThickness()});
|
||||
set_velocity_y(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::get_vertical_bottom_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
||||
for(int i : std::views::iota(0, MAX_ROWS)) {
|
||||
for(int j : std::views::iota(0, MAX_COLS)) {
|
||||
if(wall_list[i][j] == nullptr) continue;
|
||||
auto collision = find_intersection(*wall_list[i][j]);
|
||||
if(collision == CollisionDir::None) continue;
|
||||
if(collision == CollisionDir::Bottom && get_velocity().y > 0) {
|
||||
rect.setPosition({ rect.getPosition().x, wall_list[i][j]->rect.getPosition().y - rect.getSize().y });
|
||||
m_jumping = false;
|
||||
set_velocity_y(0);
|
||||
return true;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
for(auto [i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
||||
#else
|
||||
for(auto [i, j] : std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
||||
#endif
|
||||
if(wall_list[i][j] == nullptr) continue;
|
||||
auto collision = find_intersection(*wall_list[i][j]);
|
||||
if(collision == CollisionDir::None) continue;
|
||||
if(collision == CollisionDir::Bottom && get_velocity().y > 0) {
|
||||
rect.setPosition({ rect.getPosition().x, wall_list[i][j]->rect.getPosition().y - rect.getSize().y });
|
||||
m_jumping = false;
|
||||
set_velocity_y(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user