wip
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user