This commit is contained in:
DarthMooMancer
2025-10-24 14:37:31 -04:00
parent cebb2e0ce9
commit cb391573e2
8 changed files with 77 additions and 54 deletions
+11 -4
View File
@@ -63,10 +63,12 @@ CollisionDir Entity::find_intersection(Entity &entity) {
}
}
Player::Player(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, float gravity, float max_acceleration, sf::Color inside_color, sf::Color border_color) : Entity(size, pos, velocity, border_thickness, inside_color, border_color) {
Player::Player(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, float gravity, float max_acceleration, float dash_distance, sf::Color inside_color, sf::Color border_color) : Entity(size, pos, velocity, border_thickness, inside_color, border_color) {
_min_velocity = velocity;
m_acceleration = gravity;
m_jump_strength = max_acceleration;
m_dash_distance = dash_distance;
m_jumping = m_dash = false;
}
void Player::handle_movment() {
@@ -74,12 +76,16 @@ void Player::handle_movment() {
rect.move({_velocity.x, 0});
} if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) {
rect.move({-_velocity.x, 0});
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space) && !m_jumping) {
} if(timers.dash_cooldown <= 0) {
m_dash = false;
} if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W) && !m_dash && timers.dash_cooldown <= 0) {
m_dash = true;
_velocity.x = m_dash_distance;
timers.dash_cooldown = timers.dash_cooldown_max;
} if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space) && !m_jumping) {
m_jumping = true;
_velocity.y = -m_jump_strength; // push up
}
}
void Player::handle_gravity() {
@@ -110,6 +116,7 @@ void Player::vertical_no_out_of_bounds(Entity &base) {
}
}
// bool Player::get_horizontal_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
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))) {