mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 03:41:48 +01:00
Temp commit
This commit is contained in:
15
.idea/.idea.Motherload/.idea/workspace.xml
generated
15
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -10,20 +10,11 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="Add alot of memory leak fixes">
|
||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/BaseGame.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/BaseGame.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/BaseGame.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/BaseGame.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GroundTileTypeManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GroundTileTypeManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GroundTileTypeManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GroundTileTypeManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.h" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -229,6 +220,8 @@
|
||||
<workItem from="1713858589244" duration="8169000" />
|
||||
<workItem from="1713888717170" duration="3930000" />
|
||||
<workItem from="1713982171548" duration="3263000" />
|
||||
<workItem from="1713995813246" duration="2567000" />
|
||||
<workItem from="1714026889126" duration="4211000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||
<option name="closed" value="true" />
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -72,10 +72,12 @@ private:
|
||||
|
||||
Vector2f m_Vel;
|
||||
|
||||
const float m_Speed{ 400.0f };
|
||||
|
||||
std::map<Collision::CollisionDirection, WorldTile *> 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 };
|
||||
|
||||
Reference in New Issue
Block a user