mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 13:01:47 +01:00
Add window icon,
Add digging animation (Non functional)
This commit is contained in:
52
.idea/.idea.Motherload/.idea/workspace.xml
generated
52
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -10,14 +10,21 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="Add fps">
|
<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$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/Player/PlayerWalk.aseprite" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Player/PlayerWalk.aseprite" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Prog2Engine/.idea/.gitignore" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Prog2Engine/.idea/.name" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Prog2Engine/.idea/encodings.xml" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Prog2Engine/.idea/indexLayout.xml" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Prog2Engine/.idea/vcs.xml" beforeDir="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$/Engine/utils.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/utils.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Engine/utils.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/utils.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.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" />
|
<change beforePath="$PROJECT_DIR$/Game/Player.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Resources/animations/player/player_walk.png" beforeDir="false" afterPath="$PROJECT_DIR$/Resources/animations/player/player_walk.png" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Resources/test.png" beforeDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -82,10 +89,19 @@
|
|||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/algorithm" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/algorithm" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/vector" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/vector" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Engine/BaseGame.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Engine/BaseGame.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Animations/Animation.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Game/Animations/Animation.h" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Game/Animations/Animation.h" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Game.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Game.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
@@ -270,7 +286,9 @@
|
|||||||
<workItem from="1714026889126" duration="4211000" />
|
<workItem from="1714026889126" duration="4211000" />
|
||||||
<workItem from="1714046400732" duration="2462000" />
|
<workItem from="1714046400732" duration="2462000" />
|
||||||
<workItem from="1714372163827" duration="2962000" />
|
<workItem from="1714372163827" duration="2962000" />
|
||||||
<workItem from="1714459066696" duration="11199000" />
|
<workItem from="1714459066696" duration="21789000" />
|
||||||
|
<workItem from="1714640485259" duration="321000" />
|
||||||
|
<workItem from="1714641751956" duration="3705000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@@ -368,7 +386,23 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1714460546894</updated>
|
<updated>1714460546894</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="13" />
|
<task id="LOCAL-00013" summary="Add player turning (Finally)">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1714471045905</created>
|
||||||
|
<option name="number" value="00013" />
|
||||||
|
<option name="presentableId" value="LOCAL-00013" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1714471045905</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00014" summary="Update gitignore">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1714471502013</created>
|
||||||
|
<option name="number" value="00014" />
|
||||||
|
<option name="presentableId" value="LOCAL-00014" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1714471502013</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="15" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -390,7 +424,9 @@
|
|||||||
<MESSAGE value="Added Buildings Fixed rendering bugs with edges" />
|
<MESSAGE value="Added Buildings Fixed rendering bugs with edges" />
|
||||||
<MESSAGE value="Add alot of memory leak fixes" />
|
<MESSAGE value="Add alot of memory leak fixes" />
|
||||||
<MESSAGE value="Add fps" />
|
<MESSAGE value="Add fps" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Add fps" />
|
<MESSAGE value="Add player turning (Finally)" />
|
||||||
|
<MESSAGE value="Update gitignore" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Update gitignore" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|||||||
15
.idea/.idea.Prog2Engine/.idea/.gitignore
generated
vendored
15
.idea/.idea.Prog2Engine/.idea/.gitignore
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Rider ignored files
|
|
||||||
/modules.xml
|
|
||||||
/projectSettingsUpdater.xml
|
|
||||||
/contentModel.xml
|
|
||||||
/.idea.Prog2Engine.iml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# GitHub Copilot persisted chat sessions
|
|
||||||
/copilot/chatSessions
|
|
||||||
1
.idea/.idea.Prog2Engine/.idea/.name
generated
1
.idea/.idea.Prog2Engine/.idea/.name
generated
@@ -1 +0,0 @@
|
|||||||
Prog2Engine
|
|
||||||
4
.idea/.idea.Prog2Engine/.idea/encodings.xml
generated
4
.idea/.idea.Prog2Engine/.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
|
||||||
</project>
|
|
||||||
8
.idea/.idea.Prog2Engine/.idea/indexLayout.xml
generated
8
.idea/.idea.Prog2Engine/.idea/indexLayout.xml
generated
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="UserContentModel">
|
|
||||||
<attachedFolders />
|
|
||||||
<explicitIncludes />
|
|
||||||
<explicitExcludes />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
.idea/.idea.Prog2Engine/.idea/vcs.xml
generated
6
.idea/.idea.Prog2Engine/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
BIN
Assets/Player/PlayerDigStart.aseprite
Normal file
BIN
Assets/Player/PlayerDigStart.aseprite
Normal file
Binary file not shown.
@@ -146,6 +146,10 @@ void BaseGame::InitializeGameEngine()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pIcon = IMG_Load("icon.png");
|
||||||
|
SDL_SetWindowIcon(m_pWindow, m_pIcon);
|
||||||
|
|
||||||
|
// delete icon;
|
||||||
|
|
||||||
//Initialize controller
|
//Initialize controller
|
||||||
m_pGameController = nullptr;
|
m_pGameController = nullptr;
|
||||||
@@ -270,6 +274,9 @@ void BaseGame::CleanupGameEngine()
|
|||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
SDL_FreeSurface(m_pIcon);
|
||||||
|
delete m_pIcon;
|
||||||
|
|
||||||
SDL_GL_DeleteContext(m_pContext);
|
SDL_GL_DeleteContext(m_pContext);
|
||||||
|
|
||||||
SDL_DestroyWindow(m_pWindow);
|
SDL_DestroyWindow(m_pWindow);
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ private:
|
|||||||
|
|
||||||
SDL_GameController* m_pGameController;
|
SDL_GameController* m_pGameController;
|
||||||
|
|
||||||
|
SDL_Surface* m_pIcon;
|
||||||
|
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
void InitializeGameEngine();
|
void InitializeGameEngine();
|
||||||
void CleanupGameEngine();
|
void CleanupGameEngine();
|
||||||
|
|||||||
@@ -692,6 +692,12 @@ float utils::map(float value, float start1, float stop1, float start2, float sto
|
|||||||
float newVal = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
|
float newVal = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
|
||||||
return newVal;
|
return newVal;
|
||||||
}
|
}
|
||||||
|
float utils::clamp(float value, float min, float max) {
|
||||||
|
return std::max(min, std::min(value, max));
|
||||||
|
}
|
||||||
|
Vector2f utils::clamp(const Vector2f& value, const Vector2f& min, const Vector2f& max) {
|
||||||
|
return Vector2f { clamp(value.x, min.x, max.x), clamp(value.y, min.y, max.y) };
|
||||||
|
}
|
||||||
bool utils::isKeyDown(int keycode) {
|
bool utils::isKeyDown(int keycode) {
|
||||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||||
if (pStates != nullptr) {
|
if (pStates != nullptr) {
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ namespace utils
|
|||||||
Vector2f lerp(const Vector2f& a, const Vector2f& b, float t);
|
Vector2f lerp(const Vector2f& a, const Vector2f& b, float t);
|
||||||
|
|
||||||
float map(float value, float start1, float stop1, float start2, float stop2);
|
float map(float value, float start1, float stop1, float start2, float stop2);
|
||||||
|
|
||||||
|
float clamp(float value, float min, float max);
|
||||||
|
Vector2f clamp(const Vector2f& value, const Vector2f& min, const Vector2f& max);
|
||||||
#pragma endregion CollisionFunctionality
|
#pragma endregion CollisionFunctionality
|
||||||
|
|
||||||
bool isKeyDown(SDL_Keycode keycode);
|
bool isKeyDown(SDL_Keycode keycode);
|
||||||
|
|||||||
@@ -79,12 +79,12 @@ void WorldLevel::Update(float elapsedSec) {
|
|||||||
m_mousePos = Vector2f { float(mouseX), float(mouseY) };
|
m_mousePos = Vector2f { float(mouseX), float(mouseY) };
|
||||||
m_mousePos = m_pCamera->TransformMouse(m_mousePos);
|
m_mousePos = m_pCamera->TransformMouse(m_mousePos);
|
||||||
|
|
||||||
|
// for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
|
// for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
|
// m_gridManager.GetTileAtIndex(x, y)->m_Hightlight = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
|
||||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
|
||||||
m_gridManager.GetTileAtIndex(x, y)->m_Hightlight = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
m_gridManager.GetTileAtIndex(x, y)->Update(m_pCamera);
|
m_gridManager.GetTileAtIndex(x, y)->Update(m_pCamera);
|
||||||
@@ -101,21 +101,21 @@ void WorldLevel::Update(float elapsedSec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get the diogonal tiles of the selected tile
|
//Get the diogonal tiles of the selected tile
|
||||||
if (m_pSelectedTile != nullptr) {
|
// if (m_pSelectedTile != nullptr) {
|
||||||
surroundingTiles surroundingTiles = m_gridManager.GetSurroundingTiles(m_pSelectedTile);
|
// surroundingTiles surroundingTiles = m_gridManager.GetSurroundingTiles(m_pSelectedTile);
|
||||||
TileDirection direction = TileDirection::TopMiddle;
|
// TileDirection direction = TileDirection::TopMiddle;
|
||||||
const std::array<TileDirection, 8> directions = { TileDirection::TopLeft, TileDirection::TopMiddle, TileDirection::TopRight, TileDirection::MiddleLeft,
|
// const std::array<TileDirection, 8> directions = { TileDirection::TopLeft, TileDirection::TopMiddle, TileDirection::TopRight, TileDirection::MiddleLeft,
|
||||||
TileDirection::MiddleRight, TileDirection::BottomLeft, TileDirection::BottomMiddle, TileDirection::BottomRight };
|
// TileDirection::MiddleRight, TileDirection::BottomLeft, TileDirection::BottomMiddle, TileDirection::BottomRight };
|
||||||
|
//
|
||||||
for (int i = 0; i < 8; i++) {
|
// for (int i = 0; i < 8; i++) {
|
||||||
direction = directions[i];
|
// direction = directions[i];
|
||||||
if (surroundingTiles.GetTile(direction) != nullptr) {
|
// if (surroundingTiles.GetTile(direction) != nullptr) {
|
||||||
if (surroundingTiles.GetTile(direction)->GetTileType() != GroundTileTypeManager::GetInstance()->AIR) {
|
// if (surroundingTiles.GetTile(direction)->GetTileType() != GroundTileTypeManager::GetInstance()->AIR) {
|
||||||
//surroundingTiles.GetTile(direction)->m_Hightlight = true;
|
// //surroundingTiles.GetTile(direction)->m_Hightlight = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_player.Update(elapsedSec, *this);
|
m_player.Update(elapsedSec, *this);
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,13 @@ Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(P
|
|||||||
|
|
||||||
m_walkAnimation = new Animation(
|
m_walkAnimation = new Animation(
|
||||||
manager->GetTexture("animations/player/player_walk.png"),
|
manager->GetTexture("animations/player/player_walk.png"),
|
||||||
8, 0.1f, Rectf { 0, 0, 70, 70 });
|
8, 0.1f, Rectf { 0, 0, 70, 70 }, true);
|
||||||
m_turnAnimation = new Animation(
|
m_turnAnimation = new Animation(
|
||||||
manager->GetTexture("animations/player/player_turn.png"),
|
manager->GetTexture("animations/player/player_turn.png"),
|
||||||
5, 0.07f, Rectf { 0, 0, 70, 70 }, false);
|
5, 0.07f, Rectf { 0, 0, 70, 70 }, false);
|
||||||
|
m_digStartAnimation = new Animation(
|
||||||
|
manager->GetTexture("animations/player/player_dig_start.png"),
|
||||||
|
8, 0.1f, Rectf { 0, 0, 70, 70 }, false);
|
||||||
m_currentAnimation = m_walkAnimation;
|
m_currentAnimation = m_walkAnimation;
|
||||||
}
|
}
|
||||||
Player::Player(Player&& other) {
|
Player::Player(Player&& other) {
|
||||||
@@ -50,9 +53,19 @@ void Player::Draw() const {
|
|||||||
const int frameWidth = 70; //TODO: fix this
|
const int frameWidth = 70; //TODO: fix this
|
||||||
int halfFrameWidth = frameWidth / 2;
|
int halfFrameWidth = frameWidth / 2;
|
||||||
float bobOffset = m_BobUp ? 1 : 0;
|
float bobOffset = m_BobUp ? 1 : 0;
|
||||||
Vector2f drawPos = Vector2f { center.x - halfFrameWidth, center.y - halfFrameWidth + 9 + bobOffset };
|
|
||||||
|
|
||||||
m_currentAnimation->Draw(drawPos, Rectf { drawPos.x, drawPos.y, frameWidth, frameWidth });
|
float rotateOffset = std::abs(m_Vel.x) / 40;
|
||||||
|
Vector2f drawPos = Vector2f { center.x, center.y + 9 + bobOffset };
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(drawPos.x - halfFrameWidth, drawPos.y - halfFrameWidth, 0);
|
||||||
|
if (!m_Grounded && std::abs(m_Vel.y) > 0.1f) {
|
||||||
|
glRotatef(m_Direction == PlayerDirection::Left ? rotateOffset : -rotateOffset, 0, 0, 1);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
m_currentAnimation->Draw(Vector2f { 0, 0 }, Rectf { 0, 0, frameWidth, frameWidth });
|
||||||
|
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
utils::DrawEllipse(m_DigDestination, 5, 5);
|
utils::DrawEllipse(m_DigDestination, 5, 5);
|
||||||
utils::DrawEllipse(m_DigStart, 5, 5);
|
utils::DrawEllipse(m_DigStart, 5, 5);
|
||||||
}
|
}
|
||||||
@@ -60,7 +73,7 @@ void Player::ProcessImGui() {
|
|||||||
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::Text("is Grounded: %s", m_Grounded ? "true" : "false");
|
ImGui::Text("is Grounded: %s", m_Grounded ? "true" : "false");
|
||||||
ImGui::Checkbox("Draw Collision Rect", &m_DrawCollisionRect);
|
ImGui::Checkbox("Draw Collision Rect", &m_DrawCollisionRect);
|
||||||
std::string currentState {};
|
std::string currentState { "No idea" };
|
||||||
switch (m_State) {
|
switch (m_State) {
|
||||||
case PlayerState::Idle:
|
case PlayerState::Idle:
|
||||||
currentState = "Idle";
|
currentState = "Idle";
|
||||||
@@ -71,10 +84,14 @@ void Player::ProcessImGui() {
|
|||||||
case PlayerState::Walking:
|
case PlayerState::Walking:
|
||||||
currentState = "Walking";
|
currentState = "Walking";
|
||||||
break;
|
break;
|
||||||
|
case PlayerState::Flying:
|
||||||
|
currentState = "Flying";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ImGui::Text("Player State %s", currentState.c_str());
|
ImGui::Text("Player State %s", currentState.c_str());
|
||||||
ImGui::Text("Bob counter: %f", m_BobTimer);
|
ImGui::Text("Bob counter: %f", m_BobTimer);
|
||||||
ImGui::Text("Bob up: %s", m_BobUp ? "true" : "false");
|
ImGui::Text("Bob up: %s", m_BobUp ? "true" : "false");
|
||||||
|
ImGui::Text("Is Grounded: %s", m_Grounded ? "true" : "false");
|
||||||
std::string direction {};
|
std::string direction {};
|
||||||
switch (m_Direction) {
|
switch (m_Direction) {
|
||||||
case PlayerDirection::Down:
|
case PlayerDirection::Down:
|
||||||
@@ -128,7 +145,8 @@ bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) {
|
|||||||
GroundTileType type = *tile->GetTileType();
|
GroundTileType type = *tile->GetTileType();
|
||||||
//TODO: Add a list of non diggable tiles
|
//TODO: Add a list of non diggable tiles
|
||||||
|
|
||||||
if (type == GroundTileTypeManager::GetInstance()->HARD_LEFT || type == GroundTileTypeManager::GetInstance()->HARD_MIDDLE || type == GroundTileTypeManager::GetInstance()->HARD_RIGHT) {
|
if (type == GroundTileTypeManager::GetInstance()->HARD_LEFT || type == GroundTileTypeManager::GetInstance()->HARD_MIDDLE || type == GroundTileTypeManager::GetInstance()->
|
||||||
|
HARD_RIGHT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,10 +162,12 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
|
|
||||||
//check for keys
|
//check for keys
|
||||||
if (m_State != PlayerState::Digging) {
|
if (m_State != PlayerState::Digging) {
|
||||||
// m_Acc = Vector2f { 0, -100 };
|
|
||||||
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
||||||
|
// if (m_Grounded) {
|
||||||
|
m_State = PlayerState::Flying;
|
||||||
m_Vel.y = m_Speed;
|
m_Vel.y = m_Speed;
|
||||||
m_Grounded = false;
|
m_Grounded = false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
if (utils::isKeyPressed(SDL_SCANCODE_S)) {
|
if (utils::isKeyPressed(SDL_SCANCODE_S)) {
|
||||||
if (m_Grounded) {
|
if (m_Grounded) {
|
||||||
@@ -155,15 +175,12 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
this->Dig(Collision::CollisionDirection::Bottom, level);
|
this->Dig(Collision::CollisionDirection::Bottom, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
//m_Acc.y = -100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (utils::isKeyDown(SDL_SCANCODE_A)) {
|
if (utils::isKeyDown(SDL_SCANCODE_A)) {
|
||||||
if (!m_IsTurning) {
|
if (!m_IsTurning) {
|
||||||
m_walkAnimation->SetFlipped(false);
|
m_walkAnimation->SetFlipped(false);
|
||||||
m_Acc.x = -m_Speed;
|
|
||||||
}
|
}
|
||||||
|
m_Acc.x = -m_Speed;
|
||||||
if (m_Direction == PlayerDirection::Right) {
|
if (m_Direction == PlayerDirection::Right) {
|
||||||
m_IsTurning = true;
|
m_IsTurning = true;
|
||||||
m_currentAnimation = m_turnAnimation;
|
m_currentAnimation = m_turnAnimation;
|
||||||
@@ -186,11 +203,10 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (utils::isKeyDown(SDL_SCANCODE_D)) {
|
if (utils::isKeyDown(SDL_SCANCODE_D)) {
|
||||||
|
|
||||||
if (!m_IsTurning) {
|
if (!m_IsTurning) {
|
||||||
m_Acc.x = m_Speed;
|
|
||||||
m_walkAnimation->SetFlipped(true);
|
m_walkAnimation->SetFlipped(true);
|
||||||
}
|
}
|
||||||
|
m_Acc.x = m_Speed;
|
||||||
|
|
||||||
if (m_Direction == PlayerDirection::Left) {
|
if (m_Direction == PlayerDirection::Left) {
|
||||||
m_IsTurning = true;
|
m_IsTurning = true;
|
||||||
@@ -216,24 +232,24 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
|
|
||||||
m_Vel = m_Vel + m_Gravity * elapsedTime;
|
m_Vel = m_Vel + m_Gravity * elapsedTime;
|
||||||
m_Vel = m_Vel + m_Acc * elapsedTime;
|
m_Vel = m_Vel + m_Acc * elapsedTime;
|
||||||
|
m_Vel = utils::clamp(m_Vel, Vector2f { -m_Speed, -m_Speed }, Vector2f { m_Speed, m_Speed });
|
||||||
|
|
||||||
//air resistance
|
//air resistance
|
||||||
//only if not moving
|
//only if not moving
|
||||||
if (abs(m_Acc.x) < 0.1f) {
|
if (abs(m_Acc.x) < 0.1f) {
|
||||||
m_Vel.x = m_Vel.x * 0.85f;
|
m_Vel.x = m_Vel.x * 0.90f;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Acc = Vector2f { 0, 0 };
|
m_Acc = Vector2f { 0, 0 };
|
||||||
|
|
||||||
|
|
||||||
m_currentAnimation->Update(elapsedTime);
|
m_currentAnimation->Update(elapsedTime);
|
||||||
if(m_currentAnimation->IsDone()) {
|
if (m_currentAnimation->IsDone() && m_IsTurning) {
|
||||||
m_currentAnimation = m_walkAnimation; //TODO: fix this hack
|
m_currentAnimation = m_walkAnimation;
|
||||||
m_IsTurning = false;
|
m_IsTurning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Collision
|
#pragma region Collision
|
||||||
|
|
||||||
|
|
||||||
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
|
||||||
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
|
||||||
m_ContactMap[Collision::CollisionDirection::Left] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Left] = nullptr;
|
||||||
@@ -259,7 +275,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(contactTimes.begin(), contactTimes.end(), [](const std::pair<int, float>& a, const std::pair<int, float>& b) {
|
std::sort(contactTimes.begin(), contactTimes.end(), [](const std::pair<int, float>& a, const std::pair<int, float>& b)
|
||||||
|
{
|
||||||
return a.second < b.second;
|
return a.second < b.second;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -303,12 +320,12 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
if (m_State != PlayerState::Digging) { //Fix for when the state is JUST set to digging
|
if (m_State == PlayerState::Walking || m_State == PlayerState::Idle) { //Fix for when the state is JUST set to digging
|
||||||
if (m_Vel.x != 0.0f) {
|
if (std::abs(m_Vel.x) < 0.1f) {
|
||||||
m_State = PlayerState::Walking;
|
m_State = PlayerState::Idle;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_State = PlayerState::Idle;
|
m_State = PlayerState::Walking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ enum class PlayerState
|
|||||||
Idle,
|
Idle,
|
||||||
Walking,
|
Walking,
|
||||||
Digging,
|
Digging,
|
||||||
Turning
|
Turning,
|
||||||
|
Flying
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PlayerDirection
|
enum class PlayerDirection
|
||||||
@@ -102,6 +103,7 @@ private:
|
|||||||
Animation* m_currentAnimation{ nullptr };
|
Animation* m_currentAnimation{ nullptr };
|
||||||
Animation* m_walkAnimation;
|
Animation* m_walkAnimation;
|
||||||
Animation* m_turnAnimation{ nullptr };
|
Animation* m_turnAnimation{ nullptr };
|
||||||
|
Animation* m_digStartAnimation{ nullptr };
|
||||||
Animation* m_digAnimation{ nullptr };
|
Animation* m_digAnimation{ nullptr };
|
||||||
|
|
||||||
PlayerState m_State { PlayerState::Idle };
|
PlayerState m_State { PlayerState::Idle };
|
||||||
|
|||||||
BIN
Resources/animations/player/player_dig_start.png
Normal file
BIN
Resources/animations/player/player_dig_start.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Reference in New Issue
Block a user