mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 21:11:47 +01:00
Temp commit
This commit is contained in:
@@ -122,9 +122,9 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
|
||||
//check for keys
|
||||
if (m_State != PlayerState::Digging) {
|
||||
m_Vel = Vector2f { 0, -100 };
|
||||
// m_Acc = Vector2f { 0, -100 };
|
||||
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
||||
m_Vel.y = 100;
|
||||
m_Vel.y = m_Speed;
|
||||
m_Grounded = false;
|
||||
}
|
||||
if (utils::isKeyPressed(SDL_SCANCODE_S)) {
|
||||
@@ -134,12 +134,12 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_Vel.y = -100;
|
||||
//m_Acc.y = -100;
|
||||
}
|
||||
}
|
||||
if (utils::isKeyDown(SDL_SCANCODE_A)) {
|
||||
m_walkAnimation->SetFlipped(false);
|
||||
m_Vel.x = -100;
|
||||
m_Acc.x = -m_Speed;
|
||||
if (m_Grounded && !m_DidJustDigLeft) {
|
||||
//Check if the player doesnt come from digging a tile
|
||||
if (this->CanDig(Collision::CollisionDirection::Left, level)) {
|
||||
@@ -155,7 +155,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
}
|
||||
|
||||
if (utils::isKeyDown(SDL_SCANCODE_D)) {
|
||||
m_Vel.x = 100;
|
||||
m_Acc.x = m_Speed;
|
||||
m_walkAnimation->SetFlipped(true);
|
||||
if (m_Grounded && !m_DidJustDigRight) {
|
||||
//Check if the player doesnt come from digging a tile
|
||||
@@ -171,6 +171,17 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
}
|
||||
}
|
||||
|
||||
m_Vel = m_Vel + m_Gravity * elapsedTime;
|
||||
m_Vel = m_Vel + m_Acc * elapsedTime;
|
||||
|
||||
//air resistance
|
||||
//only if not moving
|
||||
if(abs(m_Acc.x) < 0.1f) {
|
||||
m_Vel.x = m_Vel.x * 0.85f;
|
||||
}
|
||||
|
||||
m_Acc = Vector2f { 0, 0 };
|
||||
|
||||
|
||||
m_walkAnimation->Update(elapsedTime);
|
||||
|
||||
@@ -266,6 +277,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
if (!m_Digging) { //TODO: fix for setting the start position
|
||||
m_Digging = true;
|
||||
m_DigStart = m_Position;
|
||||
m_Vel = Vector2f { 0, 0 };
|
||||
}
|
||||
|
||||
m_DigProgress += elapsedTime;
|
||||
|
||||
Reference in New Issue
Block a user