diff --git a/.idea/.idea.Motherload/.idea/workspace.xml b/.idea/.idea.Motherload/.idea/workspace.xml
index 98534b4..d4c72e9 100644
--- a/.idea/.idea.Motherload/.idea/workspace.xml
+++ b/.idea/.idea.Motherload/.idea/workspace.xml
@@ -11,14 +11,23 @@
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
@@ -33,6 +42,211 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -71,28 +285,28 @@
- {
- "keyToString": {
- "C++ Project.Game.executor": "Debug",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "ignore.virus.scanning.warn.message": "true",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "preferences.pluginManager",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
@@ -228,7 +442,11 @@
-
+
+
+
+
+
@@ -342,7 +560,15 @@
1714471502013
-
+
+
+ 1714654669410
+
+
+
+ 1714654669410
+
+
@@ -366,7 +592,8 @@
-
+
+
diff --git a/Assets/Player/PlayerDig.aseprite b/Assets/Player/PlayerDig.aseprite
new file mode 100644
index 0000000..efceedd
Binary files /dev/null and b/Assets/Player/PlayerDig.aseprite differ
diff --git a/Assets/Player/PlayerDigStart.aseprite b/Assets/Player/PlayerDigStart.aseprite
index db52475..f45a1ea 100644
Binary files a/Assets/Player/PlayerDigStart.aseprite and b/Assets/Player/PlayerDigStart.aseprite differ
diff --git a/Game/Animations/Animation.cpp b/Game/Animations/Animation.cpp
index eca8ebb..4fdd482 100644
--- a/Game/Animations/Animation.cpp
+++ b/Game/Animations/Animation.cpp
@@ -1,6 +1,8 @@
#include "pch.h"
#include "Animation.h"
+#include
+
#include "utils.h"
Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames), m_isLooping(isLooping), m_FrameDuration(frameDuration) {
diff --git a/Game/Animations/Animation.h b/Game/Animations/Animation.h
index 7c691d6..c9e89ea 100644
--- a/Game/Animations/Animation.h
+++ b/Game/Animations/Animation.h
@@ -23,6 +23,7 @@ public:
m_CurrentFrame = 0;
m_hasPlayedOnce = false;
m_isPlaying = true;
+ m_FrameTimer = m_FrameDuration;
}
bool IsDone() const {
return m_hasPlayedOnce && !m_isLooping;
diff --git a/Game/Game.vcxproj b/Game/Game.vcxproj
index 19f9ab8..f8ad97a 100644
--- a/Game/Game.vcxproj
+++ b/Game/Game.vcxproj
@@ -308,7 +308,9 @@
true
-
+
+
+
@@ -477,7 +479,9 @@
-
+
+
+
diff --git a/Game/Gui/Button.cpp b/Game/Gui/GuiButton.cpp
similarity index 76%
rename from Game/Gui/Button.cpp
rename to Game/Gui/GuiButton.cpp
index 64a1f34..2f47c4e 100644
--- a/Game/Gui/Button.cpp
+++ b/Game/Gui/GuiButton.cpp
@@ -1,28 +1,28 @@
#include "pch.h"
-#include "Button.h"
+#include "GuiButton.h"
#include
#include "colors.h"
#include "utils.h"
-Button::Button(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
+GuiButton::GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
m_Texture = manager->GetTexture(filePath);
if(size.x == 0 && size.y == 0) {
m_Size = Vector2f{float(m_Texture->GetWidth()), float(m_Texture->GetHeight())};
}
std::cout << "Button created" << '\n';
}
-Button::~Button() {
+GuiButton::~GuiButton() {
std::cout << "Button destroyed" << '\n';
}
-void Button::Draw() const {
+void GuiButton::Draw() const {
Rectf dest = Rectf(m_Position, m_Size);
Rectf src = Rectf(0, 0, m_Texture->GetWidth(), m_Texture->GetHeight());
if(m_IsHovered) {
m_Texture->Draw(dest, src, false);
}
}
-void Button::Update(float elapsedSec) {
+void GuiButton::Update(float elapsedSec) {
Vector2f mousePos = utils::GetMousePos();
Rectf buttonRect = Rectf(m_Position, m_Size);
diff --git a/Game/Gui/Button.h b/Game/Gui/GuiButton.h
similarity index 62%
rename from Game/Gui/Button.h
rename to Game/Gui/GuiButton.h
index 6dc9eaa..999871c 100644
--- a/Game/Gui/Button.h
+++ b/Game/Gui/GuiButton.h
@@ -2,17 +2,18 @@
#include
#include
+#include "GuiElement.h"
#include "Texture.h"
#include "../TextureManager.h"
-class Button
+class GuiButton : public GuiElement
{
public:
- Button() = default;
- Button(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
- ~Button();
- void Draw() const;
- void Update(float elapsedSec);
+ GuiButton() = default;
+ GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
+ ~GuiButton() override;
+ virtual void Draw() const override;
+ virtual void Update(float elapsedSec) override;
void SetOnClick(std::function onClick) {
m_OnClick = onClick;
diff --git a/Game/Gui/GuiElement.cpp b/Game/Gui/GuiElement.cpp
new file mode 100644
index 0000000..6b09a53
--- /dev/null
+++ b/Game/Gui/GuiElement.cpp
@@ -0,0 +1,2 @@
+#include "pch.h"
+#include "GuiElement.h"
diff --git a/Game/Gui/GuiElement.h b/Game/Gui/GuiElement.h
new file mode 100644
index 0000000..3bff5b7
--- /dev/null
+++ b/Game/Gui/GuiElement.h
@@ -0,0 +1,14 @@
+#pragma once
+
+class GuiElement
+{
+public:
+ GuiElement() = default;
+ virtual ~GuiElement() = default;
+
+ virtual void Draw() const = 0;
+ virtual void Update(float elapsedSec) = 0;
+
+private:
+
+};
diff --git a/Game/Gui/GuiMeter.cpp b/Game/Gui/GuiMeter.cpp
new file mode 100644
index 0000000..3abba58
--- /dev/null
+++ b/Game/Gui/GuiMeter.cpp
@@ -0,0 +1,18 @@
+#include "pch.h"
+#include "GuiMeter.h"
+
+#include "TextureManager.h"
+GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager): m_Position(pos), m_FrameCount(frameCount) {
+ m_Animation = new Animation(manager->GetTexture(filePath),frameCount, 0.0f, Rectf{0, 0, frameSize.x, frameSize.y}, false);
+
+}
+GuiMeter::~GuiMeter() {
+ delete m_Animation;
+}
+void GuiMeter::Draw() const {
+ m_Animation->Draw(m_Position);
+}
+void GuiMeter::Update(float elapsedSec) {
+
+
+}
\ No newline at end of file
diff --git a/Game/Gui/GuiMeter.h b/Game/Gui/GuiMeter.h
new file mode 100644
index 0000000..221fa1b
--- /dev/null
+++ b/Game/Gui/GuiMeter.h
@@ -0,0 +1,25 @@
+#pragma once
+#include "GuiElement.h"
+#include "Texture.h"
+#include "Animations/Animation.h"
+
+class TextureManager;
+
+class GuiMeter : public GuiElement
+{
+public:
+ GuiMeter() = default;
+ GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager);
+ virtual ~GuiMeter();
+
+ virtual void Draw() const override;
+ virtual void Update(float elapsedSec) override;
+
+private:
+ Animation* m_Animation{ nullptr };
+ Vector2f m_Position;
+
+ float m_Value{ 0.0f };
+
+ int m_FrameCount;
+};
diff --git a/Game/Gui/Screen.cpp b/Game/Gui/Screen.cpp
index e6fca17..05bad80 100644
--- a/Game/Gui/Screen.cpp
+++ b/Game/Gui/Screen.cpp
@@ -5,12 +5,12 @@ Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, Texture
m_Background = manager->GetTexture(filePath);
}
Screen::~Screen() {
- for (Button* b : m_Buttons) {
+ for (GuiElement* b : m_Elements) {
delete b;
}
}
void Screen::Update(float elapsedSecs) {
- for (Button* b : m_Buttons) {
+ for (GuiElement* b : m_Elements) {
b->Update(elapsedSecs);
}
}
@@ -19,7 +19,7 @@ void Screen::Draw() const {
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());
m_Background->Draw(dest, src, false);
- for (Button* b : m_Buttons) {
+ for (GuiElement* b : m_Elements) {
b->Draw();
}
}
diff --git a/Game/Gui/Screen.h b/Game/Gui/Screen.h
index 16a44f5..208a72b 100644
--- a/Game/Gui/Screen.h
+++ b/Game/Gui/Screen.h
@@ -1,7 +1,7 @@
#pragma once
#include
-#include "Button.h"
+#include "GuiButton.h"
#include "structs.h"
#include "Texture.h"
#include "../TextureManager.h"
@@ -14,7 +14,7 @@ public:
virtual ~Screen();
- void AddButton(Button* button) { m_Buttons.push_back(button); }
+ void AddElement(GuiElement* element) { m_Elements.push_back(element); }
virtual void Update(float elapsedSecs);
virtual void Draw() const;
@@ -24,5 +24,5 @@ private:
Texture* m_Background{ nullptr };
- std::vector