diff --git a/.idea/.idea.Motherload/.idea/workspace.xml b/.idea/.idea.Motherload/.idea/workspace.xml
index 47ff246..787edec 100644
--- a/.idea/.idea.Motherload/.idea/workspace.xml
+++ b/.idea/.idea.Motherload/.idea/workspace.xml
@@ -10,20 +10,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -229,6 +220,8 @@
+
+
diff --git a/Game/GridSystem/WorldTile.cpp b/Game/GridSystem/WorldTile.cpp
index d54c4ac..d6f4fb7 100644
--- a/Game/GridSystem/WorldTile.cpp
+++ b/Game/GridSystem/WorldTile.cpp
@@ -92,23 +92,23 @@ void WorldTile::Draw() {
switch (m_GroundTileType->getType()) {
case GroundTileTypes::Air: {
//check if it's all around dirt
- bool allDirt = true;
- TileDirection allDirtDirections[] { TileDirection::BottomMiddle, TileDirection::MiddleLeft, TileDirection::MiddleRight, TileDirection::TopMiddle };
- for (int i = 0; i < 3; i++) {
- const WorldTile* tile = m_SurroundingTiles.GetTile(allDirtDirections[i]);
- if (tile != nullptr) { //Tile exists
- const GroundTileTypes type = tile->GetTileType()->getType();
- if (type != GroundTileTypeManager::GetInstance()->DIRT->getType()) {
- allDirt = false;
- break;
- }
- }
- }
- if (allDirt) {
- m_pAllTexture->Draw(m_Position);
- return;
- }
- else {
+ // bool allDirt = true;
+ // TileDirection allDirtDirections[] { TileDirection::BottomMiddle, TileDirection::MiddleLeft, TileDirection::MiddleRight, TileDirection::TopMiddle };
+ // for (int i = 0; i < 3; i++) {
+ // const WorldTile* tile = m_SurroundingTiles.GetTile(allDirtDirections[i]);
+ // if (tile != nullptr) { //Tile exists
+ // const GroundTileTypes type = tile->GetTileType()->getType();
+ // if (type != GroundTileTypeManager::GetInstance()->DIRT->getType()) {
+ // allDirt = false;
+ // break;
+ // }
+ // }
+ // }
+ // if (allDirt) {
+ // m_pAllTexture->Draw(m_Position);
+ // return;
+ // }
+ // else {
this->DrawSide(TileDirection::TopLeft);
this->DrawSide(TileDirection::TopRight);
this->DrawSide(TileDirection::BottomLeft);
@@ -118,7 +118,7 @@ void WorldTile::Draw() {
this->DrawSide(TileDirection::BottomMiddle);
this->DrawSide(TileDirection::MiddleLeft);
this->DrawSide(TileDirection::MiddleRight);
- }
+ // }
break;
}
case GroundTileTypes::Dirt:
diff --git a/Game/Player.cpp b/Game/Player.cpp
index 1350171..e83441f 100644
--- a/Game/Player.cpp
+++ b/Game/Player.cpp
@@ -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;
diff --git a/Game/Player.h b/Game/Player.h
index 6fbee0c..17ebec5 100644
--- a/Game/Player.h
+++ b/Game/Player.h
@@ -72,10 +72,12 @@ private:
Vector2f m_Vel;
+ const float m_Speed{ 400.0f };
+
std::map m_ContactMap;
Vector2f m_Acc;
- Vector2f m_Gravity { 0, -9.81f };
+ Vector2f m_Gravity { 0, -1000.0f };
float m_BobTimer{ 0.0f };
const float m_BobTime{ 0.1f };
bool m_BobUp{ true };