This commit is contained in:
DarthMooMancer
2025-10-23 21:39:52 -04:00
parent 948a08f9d7
commit 8f11e24339
3 changed files with 14 additions and 7 deletions
+10
View File
@@ -59,6 +59,7 @@ 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) {
_min_velocity = velocity;
m_acceleration = gravity;
m_jump_strength = max_acceleration;
}
@@ -76,6 +77,15 @@ void Player::handle_movment() {
}
void Player::handle_gravity() {
if(get_velocity().x > _min_velocity.x) {
set_velocity_x(get_velocity().x - m_acceleration);
}
set_velocity_y(get_velocity().y + m_acceleration);
rect.move({0, get_velocity().y});
}
void Player::horizontal_no_out_of_bounds(Entity &base) {
float right_border = WIDTH - rect.getSize().x;
if(rect.getPosition().x > right_border) {