Skip to content
Snippets Groups Projects
Commit 29e513ac authored by Jonas Törnqvist's avatar Jonas Törnqvist
Browse files

s

parent 0064371f
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
Player::Player(float width, float height, float x_pos, float y_pos, float velocity)
:player_size{width, height}, player_pos{x_pos, y_pos}, player{player_size}, velocity{velocity}, velocity_y{velocity},
jumping{false}, distance{}, on_ground{true}, spawn_y_pos{y_pos}
jumping{false}, falling{false}, distance{}, on_ground{true}, spawn_y_pos{y_pos}
{}
sf::Vector2f Player::get_location() const
......@@ -31,7 +31,8 @@ void Player::check_collision(Block & b, std::string const& type)
if(player_pos.y >= b.get_pos().y+b.get_size().y-10) //Hoppar in i något
{
on_ground = false;
velocity_y = -velocity_y;
//velocity_y = -velocity_y;
velocity_y = -1
}
else if(player_pos.y <= b.get_pos().y-40) //landar på något
{
......@@ -90,7 +91,9 @@ void Player::move(sf::Time & _delta)
}
else if(player_pos.y < spawn_y_pos)
{
velocity_y = -velocity_y;
velocity_y = 0;
jumping = true;
//falling = true;
}
}
......@@ -24,6 +24,7 @@ private:
float velocity{};
float velocity_y{};
bool jumping{};
bool falling{};
float distance{};
bool on_ground{};
const float spawn_y_pos{};
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment