This commit is contained in:
Bram Verhulst
2024-06-09 22:03:29 +02:00
parent d7389411f5
commit 5f1dcd5788
76 changed files with 1532 additions and 385 deletions

View File

@@ -11,14 +11,53 @@
</component>
<component name="ChangeListManager">
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen/FuelScreen.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Game/Gui/Screens/SellScreen/SellScreen.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Game/Gui/Screens/SellScreen/SellScreen.h" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Game/Gui/Screens/SellScreen/SellSreenRow.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Game/Gui/Screens/SellScreen/SellSreenRow.h" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Game/Inventory/PlayerInventory.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Game/Inventory/PlayerInventory.h" 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/PlayerWalk.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Engine/SoundEffect.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/SoundEffect.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Engine/SoundEffect.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/SoundEffect.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Engine/Text.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Text.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Engine/Text.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Text.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Engine/colors.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/colors.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Camera.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Camera.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.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/GameManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GameManager.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/GameManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GameManager.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/Gui/GuiButton.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiButton.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/GuiButton.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiButton.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/GuiMeter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiMeter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/GuiText.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiText.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/GuiText.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/GuiText.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screen.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screen.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen/FuelScreen.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/ScreenManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/ScreenManager.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/ScreenManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/ScreenManager.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Levels/Level.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/Level.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Levels/World/Building.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/Building.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Levels/World/Building.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/Building.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/Levels/World/WorldLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Particle/Particle.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Particle/Particle.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Particle/Particle.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Particle/Particle.h" 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$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -28,7 +67,7 @@
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="d3b932df22970cf2f14e9dd79721ccae1d938a38" />
<entry key="$PROJECT_DIR$" value="d7389411f532e93b32134d230990f604e276571a" />
</map>
</option>
</component>
@@ -223,10 +262,136 @@
<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="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="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="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="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="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="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="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="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="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/stdbool.h" 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/xmemory" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/xstring" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Engine/BaseGame.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Engine/BaseGame.h" root0="FORCE_HIGHLIGHTING" />
@@ -234,8 +399,18 @@
<setting file="file://$PROJECT_DIR$/Engine/utils.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Engine/utils.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Game.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/FuelScreen/FuelScreen.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/FuelScreen/FuelScreen.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/MainScreen.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/ScreenManager.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/ScreenManager.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/SellScreen/SellScreen.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Gui/Screens/SellScreen/SellScreen.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Player.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Player.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/TextureManager.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/pch.cpp" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/pch.h" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Libraries/SDLMain/SDL2-2.26.3/include/SDL.h" root0="SKIP_HIGHLIGHTING" />
@@ -260,28 +435,28 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;C++ Project.Game.executor&quot;: &quot;Debug&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"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"
},
&quot;keyToStringList&quot;: {
&quot;rider.external.source.directories&quot;: [
&quot;C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache&quot;,
&quot;C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache&quot;,
&quot;C:\\Users\\Bram\\AppData\\Local\\Symbols\\src&quot;
"keyToStringList": {
"rider.external.source.directories": [
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
]
}
}</component>
}]]></component>
<component name="RunManager">
<configuration name="Game" type="CppProject" factoryName="C++ Project">
<configuration_1>
@@ -449,6 +624,8 @@
<workItem from="1716892028109" duration="12355000" />
<workItem from="1717443362042" duration="1602000" />
<workItem from="1717488475405" duration="1118000" />
<workItem from="1717504678935" duration="140000" />
<workItem from="1717767945752" duration="62956000" />
</task>
<task id="LOCAL-00001" summary="Rework Tile detection system">
<option name="closed" value="true" />
@@ -610,7 +787,15 @@
<option name="project" value="LOCAL" />
<updated>1715856298231</updated>
</task>
<option name="localTasksCounter" value="21" />
<task id="LOCAL-00021" summary="Do stuff">
<option name="closed" value="true" />
<created>1717504732974</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1717504732974</updated>
</task>
<option name="localTasksCounter" value="22" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -639,14 +824,8 @@
<MESSAGE value="Add Particles (basic)" />
<MESSAGE value="Add Text rendering and Hull / Fuel Meters" />
<MESSAGE value="Add sun / moon, started on score / GameManager" />
<option name="LAST_COMMIT_MESSAGE" value="Add sun / moon, started on score / GameManager" />
</component>
<component name="XDebuggerManager">
<watches-manager>
<configuration name="CppProject">
<watch expression="@ ALREADY PREPROCESSED @m_IsPlayerInHitbox" />
</configuration>
</watches-manager>
<MESSAGE value="Do stuff" />
<option name="LAST_COMMIT_MESSAGE" value="Do stuff" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
Assets/screenshot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

View File

@@ -58,3 +58,6 @@ void SoundEffect::PauseAll() {
void SoundEffect::ResumeAll() {
Mix_Resume(-1);
}
bool SoundEffect::IsPlaying() const {
return Mix_Playing(m_Channel);
}

View File

@@ -20,6 +20,8 @@ public:
static void PauseAll( );
static void ResumeAll( );
bool IsPlaying() const;
private:
Mix_Chunk* m_pMixChunk;
int m_Channel;

View File

@@ -31,3 +31,6 @@ void Text::ChangeText(const std::string& text) {
std::cout << "This is wierd??: " << m_Text << std::endl;
}
}
std::string Text::GetText() {
return m_Text;
}

View File

@@ -11,11 +11,15 @@ public:
Text() = default;
~Text();
Text(const Text& other) = delete;
Text(Text&& other) = delete;
Text& operator=(const Text& other) = delete;
Text& operator=(Text&& other) = delete;
void Draw(const Vector2f& pos) const;
void ChangeText(const std::string& text);
std::string GetText();
private:
std::string m_Text;

View File

@@ -15,4 +15,6 @@ namespace Colors
const Color4f CYAN{ 0.0f, 1.0f, 1.0f, 1.0f };
const Color4f PINK{ 1.0f, 0.0f, 0.5f, 1.0f };
const Color4f ORANGE{ 1.0f, 0.5f, 0.0f, 1.0f };
const Color4f GRAY{ 0.5f, 0.5f, 0.5f, 1.0f};
const Color4f LIGHTGRAY{ 0.8f, 0.8f, 0.8f, 1.0f};
}

View File

@@ -5,20 +5,20 @@
#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) {
m_IsLooping(isLooping), m_FrameDuration(frameDuration) {
}
void Animation::Update(float elapsedSec) {
if (m_isPlaying) {
if (m_IsPlaying) {
m_FrameTimer -= elapsedSec;
if (m_FrameTimer <= 0.0f) {
m_FrameTimer = m_FrameDuration;
++m_CurrentFrame;
if (m_CurrentFrame >= m_Frames) {
m_CurrentFrame = 0;
if (!m_isLooping) {
m_hasPlayedOnce = true;
m_isPlaying = false;
if (!m_IsLooping) {
m_HasPlayedOnce = true;
m_IsPlaying = false;
}
}
}
@@ -32,22 +32,22 @@ void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
Rectf src = m_SrcRect;
src.left += static_cast<float>(m_CurrentFrame) * src.width;
m_pTexture->Draw(dst, src, m_isFlipped);
m_pTexture->Draw(dst, src, m_IsFlipped);
}
void Animation::SetPlaying(bool isPlaying) {
m_isPlaying = isPlaying;
m_IsPlaying = isPlaying;
}
void Animation::SetFlipped(bool isFlipped) {
m_isFlipped = isFlipped;
m_IsFlipped = isFlipped;
}
void Animation::Reset() {
m_CurrentFrame = 0;
m_hasPlayedOnce = false;
m_isPlaying = true;
m_HasPlayedOnce = false;
m_IsPlaying = true;
m_FrameTimer = m_FrameDuration;
}
bool Animation::IsDone() const {
return m_hasPlayedOnce && !m_isLooping;
return m_HasPlayedOnce && !m_IsLooping;
}
int Animation::GetFrameCount() const {
return m_Frames;

View File

@@ -5,6 +5,8 @@ class Animation
{
public:
Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping = true);
~Animation() = default;
void Update(float elapsedSec);
void Draw(const Vector2f& pos) const;
@@ -30,9 +32,9 @@ private:
float m_FrameDuration { 0.1f };
bool m_isPlaying { true };
bool m_isFlipped { false };
bool m_IsPlaying { true };
bool m_IsFlipped { false };
bool m_isLooping { true };
bool m_hasPlayedOnce { false };
bool m_IsLooping { true };
bool m_HasPlayedOnce { false };
};

View File

@@ -9,9 +9,6 @@ public:
Camera(const Vector2f& position, float scale = 1);
~Camera() = default;
Camera(const Camera& other) = default;
Camera& operator=(const Camera& other) = default;
void SetPosition(const Vector2f& position) {
m_Position = position;
}

View File

@@ -58,7 +58,7 @@ void Game::Draw() const {
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
//std::cout << "KEYDOWN event: " << e.keysym.sym << std::endl;
if(e.keysym.sym == SDLK_BACKQUOTE) {
m_imGui = !m_imGui;
m_ImGui = !m_ImGui;
}
}
@@ -86,7 +86,7 @@ void Game::ProcessMouseWheelEvent(const SDL_MouseWheelEvent& e) {
m_Camera.SetScale(newScale);
}
void Game::ProcessImGui() {
if(m_imGui) {
if(m_ImGui) {
m_pCurrentLevel->ProcessImGui();
}
}

View File

@@ -47,6 +47,6 @@ private:
bool m_IsRightMouseDown {};
bool m_imGui{ true };
bool m_ImGui{ true };
};

View File

@@ -459,9 +459,158 @@
<LinkCompiled>true</LinkCompiled>
</ClCompile>
<ClCompile Include="Gui\Screen.cpp" />
<ClCompile Include="Gui\Screens\FuelScreen.cpp" />
<ClCompile Include="Gui\Screens\FuelScreen\FuelScreen.cpp">
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
<SupportJustMyCode>true</SupportJustMyCode>
<AssemblerOutput>NoListing</AssemblerOutput>
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
<BrowseInformation>true</BrowseInformation>
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
<CompileAs>Default</CompileAs>
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Column</DiagnosticsFormat>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<ErrorReporting>Prompt</ErrorReporting>
<ExpandAttributedSource>false</ExpandAttributedSource>
<ExceptionHandling>Sync</ExceptionHandling>
<EnableASAN>false</EnableASAN>
<EnableFuzzer>false</EnableFuzzer>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<GenerateModuleDependencies>false</GenerateModuleDependencies>
<GenerateSourceDependencies>false</GenerateSourceDependencies>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<IntrinsicFunctions>false</IntrinsicFunctions>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard_C>Default</LanguageStandard_C>
<MinimalRebuild>false</MinimalRebuild>
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
<OmitDefaultLibName>false</OmitDefaultLibName>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ObjectFileName>x64\Debug\</ObjectFileName>
<CallingConvention>Cdecl</CallingConvention>
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>x64\Debug\Game.pch</PrecompiledHeaderOutputFile>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessKeepComments>false</PreprocessKeepComments>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
<ShowIncludes>false</ShowIncludes>
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<BufferSecurityCheck>true</BufferSecurityCheck>
<SmallerTypeCheck>false</SmallerTypeCheck>
<SpectreMitigation>false</SpectreMitigation>
<StructMemberAlignment>Default</StructMemberAlignment>
<TrackerLogDirectory>x64\Debug\Game.tlog\</TrackerLogDirectory>
<TranslateIncludes>false</TranslateIncludes>
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
<TreatWarningAsError>false</TreatWarningAsError>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<UseFullPaths>true</UseFullPaths>
<WarningLevel>Level3</WarningLevel>
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<IntelJCCErratum>false</IntelJCCErratum>
<BuildStlModules>false</BuildStlModules>
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_UNICODE;UNICODE;</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<LinkCompiled>true</LinkCompiled>
</ClCompile>
<ClCompile Include="Gui\Screens\MainScreen.cpp" />
<ClCompile Include="Gui\Screens\ScreenManager.cpp" />
<ClCompile Include="Gui\Screens\SellScreen\SellScreen.cpp">
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<Optimization>Disabled</Optimization>
<SupportJustMyCode>true</SupportJustMyCode>
<AssemblerOutput>NoListing</AssemblerOutput>
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
<BrowseInformation>true</BrowseInformation>
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
<CompileAs>Default</CompileAs>
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Column</DiagnosticsFormat>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<ErrorReporting>Prompt</ErrorReporting>
<ExpandAttributedSource>false</ExpandAttributedSource>
<ExceptionHandling>Sync</ExceptionHandling>
<EnableASAN>false</EnableASAN>
<EnableFuzzer>false</EnableFuzzer>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<GenerateModuleDependencies>false</GenerateModuleDependencies>
<GenerateSourceDependencies>false</GenerateSourceDependencies>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<IntrinsicFunctions>false</IntrinsicFunctions>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard_C>Default</LanguageStandard_C>
<MinimalRebuild>false</MinimalRebuild>
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
<OmitDefaultLibName>false</OmitDefaultLibName>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<WholeProgramOptimization>false</WholeProgramOptimization>
<ObjectFileName>x64\Debug\</ObjectFileName>
<CallingConvention>Cdecl</CallingConvention>
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>x64\Debug\Game.pch</PrecompiledHeaderOutputFile>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessKeepComments>false</PreprocessKeepComments>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
<ShowIncludes>false</ShowIncludes>
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<BufferSecurityCheck>true</BufferSecurityCheck>
<SmallerTypeCheck>false</SmallerTypeCheck>
<SpectreMitigation>false</SpectreMitigation>
<StructMemberAlignment>Default</StructMemberAlignment>
<TrackerLogDirectory>x64\Debug\Game.tlog\</TrackerLogDirectory>
<TranslateIncludes>false</TranslateIncludes>
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
<TreatWarningAsError>false</TreatWarningAsError>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<UseFullPaths>true</UseFullPaths>
<WarningLevel>Level3</WarningLevel>
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<IntelJCCErratum>false</IntelJCCErratum>
<BuildStlModules>false</BuildStlModules>
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_UNICODE;UNICODE;</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<LinkCompiled>true</LinkCompiled>
</ClCompile>
<ClCompile Include="Gui\Screens\SellScreen\SellSreenRow.cpp" />
<ClCompile Include="Inventory\PlayerInventory.cpp" />
<ClCompile Include="Levels\Level.cpp">
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -634,9 +783,12 @@
<ClInclude Include="Gui\GuiMeter.h" />
<ClInclude Include="Gui\GuiText.h" />
<ClInclude Include="Gui\Screen.h" />
<ClInclude Include="Gui\Screens\FuelScreen.h" />
<ClInclude Include="Gui\Screens\FuelScreen\FuelScreen.h" />
<ClInclude Include="Gui\Screens\MainScreen.h" />
<ClInclude Include="Gui\Screens\ScreenManager.h" />
<ClInclude Include="Gui\Screens\SellScreen\SellScreen.h" />
<ClInclude Include="Gui\Screens\SellScreen\SellSreenRow.h" />
<ClInclude Include="Inventory\PlayerInventory.h" />
<ClInclude Include="Levels\Level.h" />
<ClInclude Include="Levels\MainMenu\MainMenuLevel.h" />
<ClInclude Include="Levels\World\Building.h" />

View File

@@ -3,16 +3,25 @@
GameManager* GameManager::m_pInstance = nullptr;
GameManager& GameManager::GetInstance() {
if (m_pInstance == nullptr) {
m_pInstance = new GameManager();
}
return *m_pInstance;
}
void GameManager::DestroyInstance() {
delete m_pInstance->m_pInventory;
delete m_pInstance->m_FuelLowSound;
delete m_pInstance;
}
void GameManager::SetMainScreen(MainScreen* pMainScreen) {
m_pMainScreen = pMainScreen;
//TODO: not the best but ¯\_(ツ)_/¯
}
void GameManager::SetPlayer(Player* pPlayer) {
m_pPlayer = pPlayer;
}
void GameManager::SetFuel(float fuel) {
m_Fuel = fuel;
//Limit to 0 - MAXa
@@ -59,7 +68,32 @@ void GameManager::Update(float elapsedSecs) {
m_pMainScreen->SetFuelMeterValue(this->GetMaxFuel() - m_Fuel);
m_pMainScreen->SetHullMeterValue(m_HullIntegrity);
m_pMainScreen->SetScore(std::to_string(m_Score));
m_pMainScreen->SetMoney("$ " + std::to_string(m_Money));
if (m_HullIntegrity <= 0 or m_Fuel <= 0) {
m_pPlayer->Die();
}
if(m_Fuel <= 20) {
if(m_FuelLowSound->IsPlaying() == false) {
m_FuelLowSound->Play(1);
}
}
}
int GameManager::GetMaxFuel() {
return 100; //TODO: change if i ever add upgrades
}
PlayerInventory* GameManager::GetInventory() {
return m_pInventory;
}
Player* GameManager::GetPlayer() {
return m_pPlayer;
}
GameManager::GameManager() {
m_pInventory = new PlayerInventory();
m_FuelLowSound = new SoundEffect{ "sound/fuel_low.wav" };
}

View File

@@ -1,14 +1,17 @@
#pragma once
#include "Player.h"
#include "Gui/Screens/MainScreen.h"
#include "Inventory/PlayerInventory.h"
class GameManager {
public:
static GameManager& GetInstance();
static GameManager* m_pInstance;
static void DestroyInstance();
void SetMainScreen(MainScreen* pMainScreen);
void SetPlayer(Player* pPlayer); //No time
void SetFuel(float fuel);
float GetFuel() const;
@@ -29,9 +32,11 @@ public:
void Update(float elapsedSecs);
int GetMaxFuel();
PlayerInventory* GetInventory();
Player* GetPlayer();
private:
GameManager() = default;
GameManager();
float m_Balance{ 0.0f };
@@ -40,5 +45,11 @@ private:
int m_Score{ 0 };
int m_Money{ 0 };
MainScreen* m_pMainScreen{ nullptr };
PlayerInventory* m_pInventory{ nullptr };
Player* m_pPlayer{ nullptr };
SoundEffect* m_FuelLowSound{ nullptr };
};

View File

@@ -89,6 +89,7 @@ WorldTile::~WorldTile() {
}
void WorldTile::Draw() {
utils::SetColor(Colors::WHITE);
switch (m_GroundTileType->GetType()) {
case GroundTileTypes::Air: {

View File

@@ -22,6 +22,7 @@ enum class GroundTileTypes {
Iron,
};
static std::map<GroundTileTypes, std::string> GroundTileTypeStrings {
{ GroundTileTypes::Air, "Air" },
{ GroundTileTypes::Dirt, "Dirt" },
@@ -35,6 +36,9 @@ static std::map<GroundTileTypes, std::string> GroundTileTypeStrings {
};
GroundTileType * getRandomGroundTile();
class GroundTileType {
@@ -140,7 +144,7 @@ public:
~WorldTile();
void Draw();
void Update(const Camera* camera); //TODO: no use
void Update(const Camera* camera);
Vector2f GetPosition() const {
return m_Position;

View File

@@ -5,20 +5,17 @@
#include "colors.h"
#include "utils.h"
GuiButton::GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
GuiButton::GuiButton(const std::string& filePath, const Vector2f& pos, const Vector2f& size, bool shouldHideDefault, TextureManager* manager): m_Position(pos), m_Size(size),
m_shouldHide(shouldHideDefault) {
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';
}
GuiButton::~GuiButton() {
std::cout << "Button destroyed" << '\n';
}
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) {
if (m_IsHovered || !m_shouldHide) {
m_Texture->Draw(dest, src, false);
}
}
@@ -39,6 +36,3 @@ void GuiButton::Update(float elapsedSec) {
m_IsPrimed = false;
}
}

View File

@@ -6,12 +6,11 @@
#include "Texture.h"
#include "../TextureManager.h"
class GuiButton : public GuiElement
{
class GuiButton : public GuiElement {
public:
GuiButton() = default;
GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
~GuiButton() override;
GuiButton(const std::string& filePath, const Vector2f& pos, const Vector2f& size, bool shouldHideDefault, TextureManager* manager);
~GuiButton() override = default;
virtual void Draw() const override;
virtual void Update(float elapsedSec) override;
@@ -28,5 +27,10 @@ private:
bool m_IsPressed { false };
bool m_IsPrimed { false };
std::function<void(void)> m_OnClick{ []() { std::cout << "Button not implemented" << std::endl; } };
bool m_shouldHide { true };
std::function<void(void)> m_OnClick { []()
{
std::cout << "Button not implemented" << std::endl;
} };
};

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "GuiMeter.h"
#include "colors.h"
#include "TextureManager.h"
#include "utils.h"
GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager): GuiMeter(
@@ -14,8 +15,9 @@ GuiMeter::~GuiMeter() {
delete m_Animation;
}
void GuiMeter::Draw() const {
utils::SetColor(Colors::WHITE);
m_Animation->Draw(m_Position, Rectf{m_Position, m_DrawSize});
utils::DrawRect(Rectf { m_Position, m_DrawSize});
// utils::DrawRect(Rectf { m_Position, m_DrawSize});
}
void GuiMeter::Update(float elapsedSec) {
const int frame = static_cast<int>(utils::map(m_Value, 0.0f, m_MaxValue, 0, (float)m_Animation->GetFrameCount()));

View File

@@ -2,6 +2,7 @@
#include "GuiText.h"
#include "colors.h"
#include "utils.h"
GuiText::GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color): m_Position(position), m_Text(new Text(text, fontPath, size, color)) {
}
@@ -11,6 +12,7 @@ GuiText::GuiText(): m_Position(100,100), m_Text(new Text("Undefined", "fonts/ver
}
void GuiText::Draw() const {
utils::SetColor(Colors::WHITE);
m_Text->Draw(m_Position);
}
@@ -20,6 +22,12 @@ void GuiText::Update(float elapsedSec) {
void GuiText::ChangeText(const std::string& text) const {
m_Text->ChangeText(text);
}
void GuiText::SetPosition(const Vector2f& pos) {
m_Position = pos;
}
GuiText::~GuiText() {
delete m_Text;
}
std::string GuiText::GetText() const {
return m_Text->GetText();
}

View File

@@ -8,12 +8,21 @@ public:
GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color);
GuiText();
GuiText(const GuiText& other) = delete;
GuiText& operator=(const GuiText& other) = delete;
GuiText(GuiText&& other) = delete;
GuiText& operator=(GuiText&& other) = delete;
void Draw() const override;
void Update(float elapsedSec) override;
void ChangeText(const std::string& text) const;
void SetPosition(const Vector2f& pos);
~GuiText() override;
std::string GetText() const;
private:
Vector2f m_Position;
Text* m_Text;

View File

@@ -1,6 +1,9 @@
#include "pch.h"
#include "Screen.h"
#include "colors.h"
#include "utils.h"
Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
if (!filePath.empty()) {
m_Background = manager->GetTexture(filePath);
@@ -23,6 +26,7 @@ void Screen::Update(float elapsedSecs) {
}
}
void Screen::Draw() const {
utils::SetColor(Colors::WHITE);
if (m_Background != nullptr) { //Incase there is no background
Rectf dest = Rectf(m_Position, m_Size);
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());

View File

@@ -12,6 +12,11 @@ public:
Screen() = default;
Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
Screen(Screen& other) = delete;
Screen& operator=(Screen& other) = delete;
Screen(Screen&& other) = delete;
Screen& operator=(Screen&& other) = delete;
virtual ~Screen();
void AddElement(GuiElement* element);

View File

@@ -1,72 +0,0 @@
#include "pch.h"
#include "FuelScreen.h"
#include "colors.h"
#include "GameManager.h"
#include "ScreenManager.h"
#include "utils.h"
FuelScreen::FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager)
{
const Vector2f fuelScreenSize = Vector2f { 492, 396 };
// Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
const Vector2f ScreenCenter = Vector2f { utils::GetViewport().x / 2, utils::GetViewport().y / 2 };
const Vector2f fuelScreenCenter = ScreenCenter - fuelScreenSize / 2;
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset;
closeButtonPos.y -= 18;
GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
closeFuelButton->SetOnClick([this]() { ScreenManager::GetInstance()->CloseScreen(); });
this->AddElement(closeFuelButton);
const Vector2f oneDollarButtonPos = Vector2f { 451, 287 };
GuiButton* fiveDollarButton = new GuiButton { "gui/fuel/5dollars.png", oneDollarButtonPos , Vector2f{0,0}, TextureManager::GetInstance() };
this->AddElement(fiveDollarButton);
const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 };
GuiButton* tenDollarButton = new GuiButton { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
this->AddElement(tenDollarButton);
const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 };
GuiButton* twentyFiveDollarButton = new GuiButton { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
this->AddElement(twentyFiveDollarButton);
const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 };
GuiButton* fiftyDollarButton = new GuiButton { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
this->AddElement(fiftyDollarButton);
const Vector2f fillTankButtonPos = Vector2f { 450, 108 };
GuiButton* fillTankButton = new GuiButton { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
this->AddElement(fillTankButton);
Vector2f offset{ 50, 320};
m_MoneyText = new GuiText {fuelScreenCenter + offset, "$ 20", "fonts/Arial.ttf", 20, Colors::YELLOW };
}
FuelScreen::~FuelScreen() {
delete m_MoneyText;
};
void FuelScreen::Draw() const {
int currentFuel = GameManager::GetInstance().GetFuel();
int maxFuel = GameManager::GetInstance().GetMaxFuel();
utils::SetColor(Colors::ORANGE);
Vector2f fuelBarPos = Vector2f { 275, 135 };
const int MAX_HEIGHT = 210;
Vector2f fuelBarSize = Vector2f { 40, utils::map(currentFuel, 0, maxFuel, 0, MAX_HEIGHT) };
utils::FillRect(Rectf{fuelBarPos, fuelBarSize});
Screen::Draw();
m_MoneyText->Draw();
}
void FuelScreen::Update(float elapsedSecs) {
Screen::Update(elapsedSecs);
m_MoneyText->ChangeText("$ " + std::to_string(GameManager::GetInstance().GetMoney()));
}

View File

@@ -1,18 +0,0 @@
#pragma once
#include "../Screen.h"
#include "Gui/GuiText.h"
class FuelScreen : public Screen
{
public:
FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
virtual ~FuelScreen() override;
virtual void Draw() const override;
virtual void Update(float elapsedSecs) override;
private:
GuiText* m_MoneyText;
};

View File

@@ -0,0 +1,137 @@
#include "pch.h"
#include "FuelScreen.h"
#include "colors.h"
#include "GameManager.h"
#include "../ScreenManager.h"
#include "utils.h"
FuelScreen::FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager) {
const Vector2f fuelScreenSize { 492, 396 };
const Vector2f ScreenCenter { utils::GetViewport().x / 2, utils::GetViewport().y / 2 };
const Vector2f fuelScreenCenter { ScreenCenter - fuelScreenSize / 2 };
m_BuySound = new SoundEffect { "sound/buy.wav" };
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset;
closeButtonPos.y -= 18;
GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
closeFuelButton->SetOnClick([this]()
{
ScreenManager::GetInstance()->CloseScreen();
});
this->AddElement(closeFuelButton);
const Vector2f oneDollarButtonPos = Vector2f { 451, 287 };
GuiButton* fiveDollarButton = new GuiButton { "gui/fuel/5dollars.png", oneDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
fiveDollarButton->SetOnClick([this]()
{
if (GameManager::GetInstance().GetMoney() > 5) {
GameManager::GetInstance().AddFuel(5);
GameManager::GetInstance().IncreaseMoney(-5);
m_BuySound->Play(0);
}
else {
std::cout << "Not enough money" << std::endl;
}
});
this->AddElement(fiveDollarButton);
const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 };
GuiButton* tenDollarButton = new GuiButton { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
tenDollarButton->SetOnClick([this]()
{
if (GameManager::GetInstance().GetMoney() > 10) {
GameManager::GetInstance().AddFuel(10);
GameManager::GetInstance().IncreaseMoney(-10);
m_BuySound->Play(0);
}
else {
std::cout << "Not enough money" << std::endl;
}
});
this->AddElement(tenDollarButton);
const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 };
GuiButton* twentyFiveDollarButton = new GuiButton { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
twentyFiveDollarButton->SetOnClick([this]()
{
if (GameManager::GetInstance().GetMoney() > 25) {
GameManager::GetInstance().AddFuel(25);
GameManager::GetInstance().IncreaseMoney(-25);
m_BuySound->Play(0);
}
else {
std::cout << "Not enough money" << std::endl;
}
});
this->AddElement(twentyFiveDollarButton);
const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 };
GuiButton* fiftyDollarButton = new GuiButton { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
fiftyDollarButton->SetOnClick([this]()
{
if (GameManager::GetInstance().GetMoney() > 50) {
GameManager::GetInstance().AddFuel(50);
GameManager::GetInstance().IncreaseMoney(-50);
m_BuySound->Play(0);
}
else {
std::cout << "Not enough money" << std::endl;
}
});
this->AddElement(fiftyDollarButton);
const Vector2f fillTankButtonPos = Vector2f { 450, 108 };
GuiButton* fillTankButton = new GuiButton { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
fillTankButton->SetOnClick([this]()
{
if (GameManager::GetInstance().GetFuel() < GameManager::GetInstance().GetMaxFuel() - 2) {
int fuelNeeded = static_cast<int>(GameManager::GetInstance().GetMaxFuel() - GameManager::GetInstance().GetFuel());
if (fuelNeeded <= GameManager::GetInstance().GetMoney()) {
GameManager::GetInstance().AddFuel(fuelNeeded);
GameManager::GetInstance().IncreaseMoney(-fuelNeeded);
m_BuySound->Play(0);
}
else {
std::cout << "Not enough money" << std::endl;
}
}
else {
std::cout << "Don't need fuel" << std::endl;
}
});
this->AddElement(fillTankButton);
Vector2f offset { 50, 320 };
m_MoneyText = new GuiText { fuelScreenCenter + offset, "$ 20", "fonts/Arial.ttf", 20, Colors::YELLOW };
}
FuelScreen::~FuelScreen() {
delete m_MoneyText;
delete m_BuySound;
};
void FuelScreen::Draw() const {
int currentFuel = GameManager::GetInstance().GetFuel();
int maxFuel = GameManager::GetInstance().GetMaxFuel();
utils::SetColor(Color4f { 99.f / 255.f, 82.f / 255.f, 36.f / 255.f, 1.f });
Vector2f fuelBarPos = Vector2f { 275, 135 };
const int MAX_HEIGHT = 210;
Vector2f fuelBarSize = Vector2f { 40, utils::map(currentFuel, 0, maxFuel, 0, MAX_HEIGHT) };
utils::FillRect(Rectf { fuelBarPos, fuelBarSize });
Screen::Draw();
m_MoneyText->Draw();
}
void FuelScreen::Update(float elapsedSecs) {
Screen::Update(elapsedSecs);
m_MoneyText->ChangeText("$ " + std::to_string(GameManager::GetInstance().GetMoney())); //Not the best but will work
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "SoundEffect.h"
#include "../../Screen.h"
#include "Gui/GuiText.h"
class FuelScreen final : public Screen {
public:
FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
virtual ~FuelScreen() override;
FuelScreen(const FuelScreen& other) = delete;
FuelScreen(FuelScreen&& other) = delete;
FuelScreen& operator=(const FuelScreen& other) = delete;
FuelScreen& operator=(FuelScreen&& other) = delete;
virtual void Draw() const override;
virtual void Update(float elapsedSecs) override;
private:
GuiText* m_MoneyText;
SoundEffect* m_BuySound { nullptr };
};

View File

@@ -20,9 +20,40 @@ MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vec
m_DepthText = new GuiText(DepthMeterPosition, "Depth: 20", "fonts/Arial.ttf", 20, Colors::YELLOW);
this->AddElement(m_DepthText);
Vector2f ScoreMeterPosition{10, ScreenSize.y - 150};
m_ScoreText = new GuiText(ScoreMeterPosition, "Score: 0", "fonts/Arial.ttf", 20, Colors::YELLOW);
Vector2f ScoreMeterPosition { 150, ScreenSize.y - 50 };
m_ScoreText = new GuiText(ScoreMeterPosition, "0", "fonts/Arial.ttf", 20, Colors::YELLOW);
this->AddElement(m_ScoreText);
Vector2f InvButtonPosition { ScreenSize.x - 150, ScreenSize.y - 60 };
float InvButtonScale = 1.2f;
m_InvButton = new GuiButton("gui/main/inv.png", InvButtonPosition, Vector2f { 58 * InvButtonScale, 55 * InvButtonScale }, false, manager);
m_InvButton->SetOnClick([]()
{
// GameManager::GetInstance().ToggleInventory();
std::cout << "Inventory button clicked" << std::endl;
});
this->AddElement(m_InvButton);
Vector2f OptionsButtonPosition { ScreenSize.x - 85, ScreenSize.y - 85 };
m_OptionsButton = new GuiButton("gui/main/options.png", OptionsButtonPosition, Vector2f { 74, 56 }, false, manager);
m_OptionsButton->SetOnClick([]()
{
// GameManager::GetInstance().ToggleOptions();
std::cout << "Options button clicked" << std::endl;
});
this->AddElement(m_OptionsButton);
m_HelpButton = new GuiButton("gui/main/help.png", Vector2f { ScreenSize.x - 50, ScreenSize.y - 50 }, Vector2f { 50, 50 }, false, manager);
m_HelpButton->SetOnClick([]()
{
// GameManager::GetInstance().ToggleHelp();
std::cout << "Help button clicked" << std::endl;
});
this->AddElement(m_HelpButton);
m_MoneyText = new GuiText(Vector2f { ScreenSize.x - 450, ScreenSize.y - 35 }, "Filler Text", "fonts/Arial.ttf", 25, Colors::YELLOW);
this->AddElement(m_MoneyText);
}
MainScreen::~MainScreen() = default;
void MainScreen::Draw() const {
@@ -43,4 +74,6 @@ void MainScreen::SetDepth(const std::string& text) const {
void MainScreen::SetScore(const std::string& text) const {
m_ScoreText->ChangeText(text);
}
void MainScreen::SetMoney(const std::string& text) const {
m_MoneyText->ChangeText(text);
}

View File

@@ -3,7 +3,7 @@
#include "Gui/GuiText.h"
#include "Gui/Screen.h"
class MainScreen: public Screen {
class MainScreen final : public Screen {
public:
explicit MainScreen(TextureManager* manager);
virtual ~MainScreen() override;
@@ -16,6 +16,7 @@ public:
void SetDepth(const std::string& text) const;
void SetScore(const std::string& text) const;
void SetMoney(const std::string& text) const;
private:
GuiMeter* m_FuelMeter;
@@ -23,5 +24,10 @@ private:
GuiText* m_DepthText;
GuiText* m_ScoreText;
GuiText* m_MoneyText;
GuiButton* m_InvButton;
GuiButton* m_OptionsButton;
GuiButton* m_HelpButton;
};

View File

@@ -1,7 +1,8 @@
#include "pch.h"
#include "ScreenManager.h"
#include "FuelScreen.h"
#include "FuelScreen/FuelScreen.h"
#include "SellScreen/SellScreen.h"
#include "utils.h"
ScreenManager* ScreenManager::m_pInstance = nullptr;
@@ -14,7 +15,7 @@ ScreenManager* ScreenManager::GetInstance() {
m_pInstance = new ScreenManager();
}
if (!m_pInstance->m_AreScreensInitialized) {
m_pInstance->InitializeScreens(); //TODO: Ask if this a hack
m_pInstance->InitializeScreens();
m_pInstance->m_AreScreensInitialized = true;
}
return m_pInstance;
@@ -37,7 +38,7 @@ void ScreenManager::CloseScreen() {
}
}
bool ScreenManager::IsScreenOpen() {
bool ScreenManager::IsScreenOpen() const {
return m_IsScreenOpen;
}
ScreenManager::~ScreenManager() {
@@ -51,8 +52,7 @@ void ScreenManager::InitializeScreens() {
Vector2f sellScreenSize = Vector2f { 533, 398 };
Vector2f sellScreenCenter = Vector2f { utils::GetViewport().x / 2 - sellScreenSize.x / 2, utils::GetViewport().y / 2 - sellScreenSize.y / 2 };
m_SellScreen = new Screen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, TextureManager::GetInstance() };
m_SellScreen = new SellScreen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, TextureManager::GetInstance() };
//m_Button = Button { "gui/close.png", closeButtonPos, closeButtonSize, TextureManager::GetInstance() };
}

View File

@@ -3,8 +3,7 @@
class ScreenManager
{
class ScreenManager {
public:
static ScreenManager* GetInstance();
static void DestroyInstance();
@@ -12,14 +11,17 @@ public:
void OpenScreen(Screen* screen);
void CloseScreen();
Screen* GetCurrentScreen() const { return m_currentScreen; }
bool IsScreenOpen();
Screen * GetCurrentScreen() const {
return m_currentScreen;
}
bool IsScreenOpen() const;
static ScreenManager* m_pInstance;
static Screen* m_FuelScreen;
static Screen* m_SellScreen;
private:
ScreenManager() = default;
~ScreenManager();

View File

@@ -0,0 +1,116 @@
#include "pch.h"
#include "SellScreen.h"
#include "colors.h"
#include "GameManager.h"
#include "SellSreenRow.h"
#include "../ScreenManager.h"
#include "utils.h"
SellScreen::SellScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager) {
const Vector2f sellScreenSize { 492, 396 };
// Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
const Vector2f ScreenCenter = Vector2f { utils::GetViewport().x / 2, utils::GetViewport().y / 2 };
const Vector2f sellScreenCenter = ScreenCenter - sellScreenSize / 2;
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
Vector2f closeButtonPos = sellScreenCenter + closeButtonOffset;
closeButtonPos.y -= 18;
GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() };
closeFuelButton->SetOnClick([this]()
{
ScreenManager::GetInstance()->CloseScreen();
});
this->AddElement(closeFuelButton);
std::string HeaderText = "Cargo Bay Qty. Value Total Value"; //Dont ask
Vector2f headerTextPos = Vector2f { 285, 400 };
GuiText* m_HeaderText = new GuiText { headerTextPos, HeaderText, "fonts/Arial.ttf", 14, Colors::LIGHTGRAY };
this->AddElement(m_HeaderText);
std::string sellAllPath = "gui/sell/sellall.png";
Vector2f sellAllPos = Vector2f { 410, 100 };
GuiButton* sellAllButton = new GuiButton { sellAllPath, sellAllPos, Vector2f { 97, 27 }, false, TextureManager::GetInstance() };
sellAllButton->SetOnClick([this]()
{
this->SellAll();
});
this->AddElement(sellAllButton);
std::string totalSell = "Balls";
Vector2f totalSellPos = Vector2f { 590, 105 };
m_TotalMoneyText = new GuiText { totalSellPos, totalSell, "fonts/Arial.ttf", 18, Colors::GREEN };
this->AddElement(m_TotalMoneyText);
}
SellScreen::~SellScreen() {
for (SellSreenRow* row : m_Rows) {
delete row;
}
}
void SellScreen::Draw() const {
Screen::Draw();
for (const SellSreenRow* row : m_Rows) {
row->Draw();
}
// m_TotalMoneyText->Draw();
utils::SetColor(Colors::GREEN);
utils::DrawLine(550, 130, 650, 130);
}
void SellScreen::Update(float elapsedSecs) {
Screen::Update(elapsedSecs);
if (m_AreRowsDirty) {
//remake rows
m_AreRowsDirty = false;
for (SellSreenRow* row : m_Rows) {
delete row;
}
m_Rows.clear();
std::vector<ItemStack *> items = GameManager::GetInstance().GetInventory()->GetItems();
int totalWorth { 0 };
int index { 0 }; //Fix to not overshoot when an empty item is in the inventory
for (ItemStack* item : items) {
if (item->m_ItemType == InventoryItem::Empty) {
continue;
}
SellSreenRow* row = new SellSreenRow(*item, Vector2f { 250, (float)360 - index * 30 }, Vector2f { 400, 30 });
totalWorth += item->m_Quantity * PlayerInventory::GetItemValue(item->m_ItemType);
m_Rows.push_back(std::move(row));
index++;
}
m_TotalMoneyText->ChangeText("$" + std::to_string(GameManager::GetInstance().GetInventory()->GetTotalValue()));
int characterCount = m_TotalMoneyText->GetText().length();
m_TotalMoneyText->SetPosition(Vector2f { (float)610 - characterCount * 10, 105 });
}
for (SellSreenRow* row : m_Rows) {
row->Update(elapsedSecs);
}
}
void SellScreen::MarkDirty() {
m_AreRowsDirty = true;
}
void SellScreen::SellAll() {
PlayerInventory* inventory = GameManager::GetInstance().GetInventory();
std::vector<ItemStack *> items = inventory->GetItems();
if (items.empty()) {
return;
}
int totalWorth { 0 };
for (ItemStack* item : items) {
if (item->m_ItemType == InventoryItem::Empty) {
continue;
}
totalWorth += item->m_Quantity * PlayerInventory::GetItemValue(item->m_ItemType);
inventory->RemoveItem(item);
}
GameManager::GetInstance().IncreaseMoney(totalWorth);
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "SellSreenRow.h"
#include "../../Screen.h"
#include "Gui/GuiText.h"
class SellScreen final : public Screen {
public:
SellScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
virtual ~SellScreen() override;
virtual void Draw() const override;
virtual void Update(float elapsedSecs) override;
void MarkDirty();
void SellAll();
private:
GuiText* m_TotalMoneyText;
std::vector<SellSreenRow *> m_Rows;
bool m_AreRowsDirty { true };
};

View File

@@ -0,0 +1,45 @@
#include "pch.h"
#include "SellSreenRow.h"
#include "colors.h"
#include "utils.h"
SellSreenRow::SellSreenRow(const ItemStack& item, const Vector2f& pos, const Vector2f& size): m_Item(item), m_Pos(pos), m_Size(size) {
m_NameText = new Text(PlayerInventory::GetItemName(item.m_ItemType), "fonts/verdana.ttf", 12, Colors::GREEN);
m_CalculationText = new Text("Hello World", "fonts/verdana.ttf", 14, Colors::GREEN);
this->GenerateCalcString();
m_Icon = PlayerInventory::GetItemIcon(item.m_ItemType);
}
SellSreenRow::~SellSreenRow() {
delete m_NameText;
delete m_CalculationText;
}
void SellSreenRow::Draw() const {
//The row has, The icon, The name, The amount, an X, the value, an =, the total value
//The icon
Vector2f iconPos { m_Pos.x + 10, m_Pos.y + 2 };
m_Icon->Draw(iconPos);
//The name
Vector2f namePos { iconPos.x + 50, m_Pos.y + 8 };
m_NameText->Draw(namePos);
Vector2f amountPos { namePos.x + 100, m_Pos.y + 8 };
m_CalculationText->Draw(amountPos);
utils::SetColor(Colors::GREEN);
utils::DrawRect(Rectf { m_Pos, m_Size });
}
void SellSreenRow::Update(float elapsedSecs) {
// m_NameText->ChangeText("EXAMPLE");
// m_CalculationText->ChangeText(std::to_string(m_Item.m_Quantity));
GenerateCalcString();
}
void SellSreenRow::GenerateCalcString() {
std::string amount = std::to_string(m_Item.m_Quantity);
std::string value = std::to_string(PlayerInventory::GetItemValue(m_Item.m_ItemType));
std::string totalValue = std::to_string(PlayerInventory::GetItemValue(m_Item.m_ItemType) * m_Item.m_Quantity);
// NAME AMOUNT X VALUE = TOTAL VALUE
std::string text = amount + " x $" + value + " = " + totalValue + "$";
m_CalculationText->ChangeText(text);
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include "Text.h"
#include "TextureManager.h"
#include "Inventory/PlayerInventory.h"
class SellSreenRow {
public:
SellSreenRow(const ItemStack& item, const Vector2f& pos, const Vector2f& size);
~SellSreenRow();
SellSreenRow(const SellSreenRow& other) = delete;
SellSreenRow(SellSreenRow&& other) = delete;
SellSreenRow& operator=(const SellSreenRow& other) = delete;
SellSreenRow& operator=(SellSreenRow&& other) = delete;
void Draw() const;
void Update(float elapsedSecs);
private:
void GenerateCalcString();
ItemStack m_Item;
Vector2f m_Pos;
Vector2f m_Size;
Text* m_NameText;
Text* m_CalculationText;
Texture* m_Icon;
};

View File

@@ -0,0 +1,130 @@
#include "pch.h"
#include "PlayerInventory.h"
#include <iostream>
#include "Gui/Screens/ScreenManager.h"
#include "Gui/Screens/SellScreen/SellScreen.h"
PlayerInventory::PlayerInventory() {
}
PlayerInventory::~PlayerInventory() {
for(ItemStack* stack : m_Items) {
delete stack;
}
}
void PlayerInventory::ClearInventory() {
for (ItemStack* stack : m_Items) {
delete stack;
}
}
int PlayerInventory::GetTotalValue() const {
int totalValue{ 0 };
for (ItemStack* stack : m_Items) {
totalValue += stack->m_Quantity * GetItemValue(stack->m_ItemType);
}
return totalValue;
}
void PlayerInventory::AddItem(const ItemStack& item) {
dynamic_cast<SellScreen*>(ScreenManager::m_SellScreen)->MarkDirty();
//Check if its in the array
for(ItemStack* stack : m_Items) {
if(stack->m_ItemType == item.m_ItemType) {
std::cout << "Added item to inventory: Existing Array" << std::endl;
stack->m_Quantity += item.m_Quantity;
if(stack->m_Quantity == 2){}
return;
}
}
m_Items.push_back(new ItemStack(item));
std::cout << "Added item to inventory: New Item" << std::endl;
}
void PlayerInventory::RemoveItem(ItemStack* item) {
//Remove the item
for (size_t i = 0; i < m_Items.size(); i++) {
if(m_Items[i] == item) {
delete m_Items[i];
m_Items.erase(m_Items.begin() + i);
dynamic_cast<SellScreen*>(ScreenManager::m_SellScreen)->MarkDirty();
return;
}
}
}
std::vector<ItemStack*> PlayerInventory::GetItems() const {
return m_Items;
}
InventoryItem PlayerInventory::GetItemByType(GroundTileType* tile) {
if(tile == nullptr) {
return InventoryItem::Empty;
}
switch (tile->GetType()) {
case GroundTileTypes::Bronze:
return InventoryItem::Bronzium;
case GroundTileTypes::Air:
return InventoryItem::Empty;
case GroundTileTypes::Gold:
return InventoryItem::Goldium;
case GroundTileTypes::Iron:
return InventoryItem::Ironium;
default:
return InventoryItem::Empty;
}
}
std::string PlayerInventory::GetItemName(InventoryItem item) {
switch (item) {
case InventoryItem::Bronzium:
return "Bronzium";
case InventoryItem::Diamond:
return "Diamond";
case InventoryItem::Einsteinium:
return "Einsteinium";
case InventoryItem::Emerald:
return "Emerald";
case InventoryItem::Goldium:
return "Goldium";
case InventoryItem::Ironium:
return "Ironium";
case InventoryItem::Platnium:
return "Platnium";
case InventoryItem::Ruby:
return "Ruby";
case InventoryItem::Silverium:
return "Silverium";
case InventoryItem::Special:
return "Special";
default:
return "Empty";
}
}
int PlayerInventory::GetItemValue(InventoryItem item) {
switch(item) {
case InventoryItem::Bronzium:
return 60;
case InventoryItem::Ironium:
return 30;
case InventoryItem::Silverium:
return 100;
case InventoryItem::Goldium:
return 250;
case InventoryItem::Platinum:
return 750;
case InventoryItem::Einsteinium:
return 2000;
case InventoryItem::Emerald:
return 5000;
case InventoryItem::Ruby:
return 20000;
case InventoryItem::Diamond:
return 100000;
default:
return 0;
}
}
Texture* PlayerInventory::GetItemIcon(InventoryItem item) {
std::string texturePath = "gui/sell/icons/";
std::string itemName = GetItemName(item);
texturePath += itemName + ".png";
return TextureManager::GetInstance()->GetTexture(texturePath);
}

View File

@@ -0,0 +1,51 @@
#pragma once
#include <vector>
#include "GridSystem/WorldTile.h"
enum class InventoryItem {
Empty,
Bronzium,
Diamond,
Einsteinium,
Emerald,
Goldium,
Ironium,
Platinum,
Platnium,
Ruby,
Silverium,
Special,
};
struct ItemStack {
ItemStack(InventoryItem type, int quantity) : m_ItemType{ type }, m_Quantity{ quantity } {}
InventoryItem m_ItemType;
int m_Quantity{ 0 };
};
class PlayerInventory final {
public:
PlayerInventory();
~PlayerInventory();
PlayerInventory(PlayerInventory& other) = delete;
PlayerInventory& operator=(PlayerInventory& other) = delete;
PlayerInventory(PlayerInventory&& other) = delete;
PlayerInventory& operator=(PlayerInventory&& other) = delete;
void ClearInventory();
int GetTotalValue() const;
void AddItem(const ItemStack& item);
void RemoveItem(ItemStack* item);
std::vector<ItemStack*> GetItems() const;
InventoryItem GetItemByType(GroundTileType* tile);
static std::string GetItemName(InventoryItem item);
static int GetItemValue(InventoryItem item);
static Texture* GetItemIcon(InventoryItem item);
private:
std::vector<ItemStack*> m_Items;
};

View File

@@ -11,6 +11,8 @@ public:
Level(const Level& other) = default;
Level(Level&& other) = default;
Level& operator=(const Level& other) = default;
Level& operator=(Level&& other) = default;
virtual void Update(float elapsedSec) = 0;
virtual void Draw() const = 0;

View File

@@ -5,16 +5,16 @@
#include <utility>
#include "colors.h"
#include "GameManager.h"
#include "Player.h"
#include "utils.h"
Building::Building(const std::string& filePath, const Vector2f& position, const Rectf& boundingBox, TextureManager* pTextureManager): m_Position(position),
m_BoundingBox(boundingBox) {
m_Texture = pTextureManager->GetTexture(filePath);
m_Size = Vector2f(m_Texture->GetWidth(), m_Texture->GetHeight());
std::cout << "i like kids" << std::endl;
}
Building::~Building() = default;
void Building::Draw() const {
utils::SetColor(Colors::WHITE);
m_Texture->Draw(m_Position);
utils::SetColor(Colors::GREEN);
Rectf temp = m_BoundingBox;
@@ -24,7 +24,10 @@ void Building::Draw() const {
}
void Building::Update(float dt, const Rectf& objectBoundingBox) {
if (IsObjectInHitbox(objectBoundingBox)) {
if (!m_IsPlayerInHitbox) { //TODO: what
Player* player = GameManager::GetInstance().GetPlayer();
float speed = player->GetVelocity().Length();
if (speed < 100.0f) {
if (!m_IsPlayerInHitbox) {
m_IsPlayerInHitbox = true;
if (m_OnEnterHitbox != nullptr) {
m_OnEnterHitbox();
@@ -34,6 +37,8 @@ void Building::Update(float dt, const Rectf& objectBoundingBox) {
}
}
}
}
else {
m_IsPlayerInHitbox = false;
}

View File

@@ -8,12 +8,8 @@ class Building
{
public:
Building(const std::string& filePath, const Vector2f& position, const Rectf& boundingBox, TextureManager* pTextureManager);
// Building(const Building& other) = default;
// Building(Building&& other) = default;
// Building& operator=(const Building& other) = default;
// Building& operator=(Building&& other) = default;
~Building();
~Building() = default;
void Draw() const;
void Update(float dt, const Rectf& objectBoundingBox);

View File

@@ -46,8 +46,11 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
m_GridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
m_GridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
m_Buildings.emplace_back(new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() });
Building* mineralBuilding = new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() };
mineralBuilding->SetOnEnterHitbox([]() {
ScreenManager::GetInstance()->OpenScreen(ScreenManager::m_SellScreen);
});
m_Buildings.emplace_back(mineralBuilding);
m_GridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
m_GridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
m_GridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
@@ -70,7 +73,7 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
m_GridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
m_topCover = TextureManager::GetInstance()->GetTexture("topBackground.png");
m_TopCover = TextureManager::GetInstance()->GetTexture("topBackground.png");
m_MainScreen = new MainScreen(TextureManager::GetInstance());
GameManager::GetInstance().SetMainScreen(m_MainScreen);
@@ -80,13 +83,28 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
GameManager::GetInstance().SetFuel(100);
GameManager::GetInstance().SetHullIntegrity(100);
GameManager::GetInstance().SetPlayer(&m_Player);
m_BackgroundMusic = new SoundStream("sound/bgm.wav");
m_BackgroundMusic->Play(0);
}
WorldLevel::~WorldLevel() {
delete m_MainScreen;
delete m_Sun;
delete m_Moon;
delete m_BackgroundMusic;
for (Building* building : m_Buildings) {
delete building;
}
GameManager::DestroyInstance();
}
void WorldLevel::Update(float elapsedSec) {
m_Fps = 1 / elapsedSec;
@@ -156,7 +174,7 @@ void WorldLevel::Update(float elapsedSec) {
GameManager::GetInstance().Update(elapsedSec);
m_MainScreen->SetDepth(std::to_string((int)-m_Player.GetPosition().y - 50) + " ft.");
m_MainScreen->SetScore("Score: " + std::to_string(GameManager::GetInstance().GetScore()));
m_MainScreen->SetScore(std::to_string(GameManager::GetInstance().GetScore()));
// m_MainScreen->SetFuelMeterValue(GameManager::GetInstance().GetFuel());
// m_MainScreen->SetHullMeterValue(GameManager::GetInstance().GetHullIntegrity());
m_MainScreen->Update(elapsedSec);
@@ -178,7 +196,7 @@ void WorldLevel::Draw() const {
m_Moon->Draw();
// m_topCover->Draw(Vector2f{-850,-70} );
m_topCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32});
m_TopCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32});
for (Collision::CollisionRect rect : m_Rects) {
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);

View File

@@ -8,6 +8,7 @@
#include "Camera.h"
#include "OrbitingObject.h"
#include "SoundEffect.h"
#include "SoundStream.h"
#include "Text.h"
#include "Gui/GuiMeter.h"
#include "Gui/Screens/MainScreen.h"
@@ -19,8 +20,12 @@ public:
WorldLevel(Camera* camera, Rectf viewport);
virtual ~WorldLevel() override;
WorldLevel(const WorldLevel& other) = default;
WorldLevel(WorldLevel&& other) = default;
WorldLevel(const WorldLevel& other) = delete;
WorldLevel& operator=(const WorldLevel& other) = delete;
WorldLevel(WorldLevel&& other) = delete;
WorldLevel& operator=(WorldLevel&& other) = delete;
void Update(float elapsedSec) override;
void Draw() const override;
@@ -40,6 +45,8 @@ private:
Player m_Player;
Vector2f m_MousePos {};
SoundStream* m_BackgroundMusic;
Rectf m_Viewport;
ScreenManager* m_ScreenManager;
@@ -54,7 +61,7 @@ private:
OrbitingObject* m_Sun{ nullptr };
OrbitingObject* m_Moon{ nullptr };
Texture* m_topCover{ nullptr };
Texture* m_TopCover{ nullptr };
// ImGui Vars

View File

@@ -1,10 +1,11 @@
#include "pch.h"
#include "Particle.h"
Particle::Particle(const Vector2f& pos, const Vector2f& velocity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime },
Particle::Particle(const Vector2f& pos, const Vector2f& velocity,const Vector2f& gravity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime }, m_Gravity(gravity),
m_pTexture { pTexture } {
}
void Particle::Update(float elapsedSec) {
m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
// m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
m_Acceleration = m_Gravity;
m_Velocity += m_Acceleration * elapsedSec;
m_Position += m_Velocity * elapsedSec;
m_LifeTime -= elapsedSec;
@@ -12,8 +13,12 @@ void Particle::Update(float elapsedSec) {
}
void Particle::Draw() const {
m_pTexture->Draw(m_Position);
m_pTexture->Draw(m_Position, {}, m_Flipped);
}
bool Particle::IsDead() const {
return m_LifeTime <= 0.0f;
}
void Particle::SetFlipped(bool flipped) {
m_Flipped = flipped;
}

View File

@@ -4,16 +4,22 @@
class Particle {
public:
Particle() = default;
Particle(const Vector2f& pos, const Vector2f& velocity,float lifetime, Texture* pTexture);
Particle(const Vector2f& pos, const Vector2f& velocity, const Vector2f& gravity, float lifetime, Texture* pTexture);
~Particle() = default;
void Update(float elapsedSec);
void Draw() const;
bool IsDead() const;
void SetFlipped(bool flipped);
private:
Vector2f m_Position;
Vector2f m_Velocity;
Vector2f m_Acceleration;
Vector2f m_Gravity;
bool m_Flipped{ false };
float m_LifeTime;
Texture* m_pTexture;

View File

@@ -18,43 +18,72 @@ Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(P
m_ContactMap[Collision::CollisionDirection::Left] = nullptr;
m_ContactMap[Collision::CollisionDirection::Right] = nullptr;
m_walkAnimation = new Animation(
m_WalkAnimation = new Animation(
manager->GetTexture("animations/player/player_walk.png"),
8, 0.1f, Rectf { 0, 0, 70, 70 }, true);
m_turnAnimation = new Animation(
m_TurnAnimation = new Animation(
manager->GetTexture("animations/player/player_turn.png"),
5, 0.07f, Rectf { 0, 0, 70, 70 }, false);
m_digStartAnimation = new Animation(
m_DigStartAnimation = new Animation(
manager->GetTexture("animations/player/player_dig_start.png"),
7, 0.07f, Rectf { 0, 0, 70, 70 }, false);
m_digAnimation = new Animation(
m_DigAnimation = new Animation(
manager->GetTexture("animations/player/player_dig.png"),
7, 0.05f, Rectf { 0, 0, 70, 70 }, true);
m_flyStartAnimation = new Animation(
m_FlyStartAnimation = new Animation(
manager->GetTexture("animations/player/player_fly_start.png"),
12, 0.05f, Rectf { 0, 0, 70, 70 }, false);
m_flyAnimation = new Animation(
m_FlyAnimation = new Animation(
manager->GetTexture("animations/player/player_fly.png"),
5, 0.01f, Rectf { 0, 0, 70, 70 }, true);
m_flyTurnAnimation = new Animation(
m_FlyTurnAnimation = new Animation(
manager->GetTexture("animations/player/player_fly_turn.png"),
3, 0.05f, Rectf { 0, 0, 70, 70 }, false);
m_currentAnimation = m_walkAnimation;
m_DieStartAnimation = new Animation(
manager->GetTexture("animations/player/player_die_start.png"),
11, 0.05f, Rectf { 0, 0, 100, 100 }, false);
m_DieLoopAnimation = new Animation(
manager->GetTexture("animations/player/player_die_loop.png"),
4, 0.05f, Rectf { 0, 0, 100, 100 }, true);
m_CurrentAnimation = m_WalkAnimation;
m_IdleSound = new SoundEffect("sound/idle.wav");
m_FlySound = new SoundEffect("sound/fly.wav");
m_DigSound = new SoundEffect("sound/drill.wav");
m_DigSound->SetVolume(64);
m_WalkSound = new SoundEffect("sound/walk.wav");
m_CurrentSound = m_IdleSound;
}
Player::~Player() {
delete m_walkAnimation;
delete m_turnAnimation;
delete m_digAnimation;
delete m_digStartAnimation;
delete m_WalkAnimation;
delete m_TurnAnimation;
delete m_DigAnimation;
delete m_DigStartAnimation;
delete m_flyStartAnimation;
delete m_flyAnimation;
delete m_flyTurnAnimation;
delete m_IdleSound;
delete m_FlySound;
delete m_DigSound;
delete m_WalkSound;
delete m_FlyStartAnimation;
delete m_FlyAnimation;
delete m_FlyTurnAnimation;
delete m_DieStartAnimation;
delete m_DieLoopAnimation;
for (Particle* particle : m_DigParticles) {
delete particle;
}
}
Collision::CollisionRect Player::GetCollisionRect() const {
@@ -81,13 +110,30 @@ void Player::Draw() const {
glRotatef(m_Direction == PlayerDirection::Left ? rotateOffset : -rotateOffset, 0, 0, 1);
}
{
m_currentAnimation->Draw(Vector2f { 0, 0 }, Rectf { 0, 0, frameWidth, frameWidth });
utils::SetColor(Colors::WHITE);
m_CurrentAnimation->Draw(Vector2f { 0, 0 }, Rectf { 0, 0, frameWidth, frameWidth });
utils::SetColor(Colors::GREEN);
}
glPopMatrix();
utils::FillEllipse(m_OutletPos + m_Position, 5, 5);
for (Particle* particle : m_DigParticles) {
utils::SetColor(Colors::WHITE);
particle->Draw();
}
for (Particle* particle : m_SmokeParticles) {
utils::SetColor(Colors::WHITE);
particle->Draw();
}
}
void Player::Die() {
m_IsDead = true;
m_CurrentAnimation = m_DieStartAnimation;
m_HasPlayedDeathAnimation = false;
}
void Player::ProcessImGui() {
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
@@ -152,6 +198,7 @@ void Player::Dig(Collision::CollisionDirection dir, WorldLevel& level) {
//Set the digging location in the center of the destination tile;
const WorldTile* tile = m_ContactMap[dir];
m_ToAddPoints = tile->GetTileType()->GetValue();
m_ToAddTile = tile->GetTileType();
//Add case for bottom because otherwise i clip through the floor
m_DigDestination = tile->GetPosition();
if (dir == Collision::Bottom) {
@@ -171,7 +218,10 @@ bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) {
return false;
}
GroundTileType type = *tile->GetTileType();
//TODO: Add a list of non diggable tiles
if (type == GroundTileTypeManager::GetInstance()->STONE) {
return false;
}
if (type == GroundTileTypeManager::GetInstance()->HARD_LEFT || type == GroundTileTypeManager::GetInstance()->HARD_MIDDLE || type == GroundTileTypeManager::GetInstance()->
HARD_RIGHT) {
@@ -180,14 +230,32 @@ bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) {
return true;
}
void Player::ChangeSound(SoundEffect* sound) {
m_PrevSound = m_CurrentSound;
// m_CurrentSound->Stop();
m_CurrentSound = sound;
}
void Player::Update(float elapsedTime, WorldLevel& level) {
if (m_IsDead) {
m_CurrentAnimation->Update(elapsedTime);
if (m_CurrentAnimation == m_DieStartAnimation) {
if (m_CurrentAnimation->IsDone()) {
m_CurrentAnimation = m_DieLoopAnimation;
}
}
return;
}
m_BobTimer += elapsedTime;
if (m_BobTimer >= m_BobTime) {
m_BobUp = !m_BobUp;
m_BobTimer = 0.0f;
}
std::vector<Particle *> particlesToDelete {};
for (Particle* particle : m_DigParticles) {
particle->Update(elapsedTime);
@@ -200,6 +268,27 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
delete particle;
}
m_SmokeTimer += elapsedTime;
if (m_SmokeTimer >= m_SmokeTime) {
m_SmokeTimer = 0.0f;
Vector2f Dir { static_cast<float>(m_Direction == PlayerDirection::Left ? 30 : -30), 20 };
Particle* NewSmokeParticle = new Particle(m_OutletPos + m_Position, Dir, Vector2f { 0.0f, 9.81f * 30}, 5.f, TextureManager::GetInstance()->GetTexture("particles/smoke.png"));
NewSmokeParticle->SetFlipped(m_Direction == PlayerDirection::Left);
m_SmokeParticles.push_back(NewSmokeParticle);
}
std::vector<Particle*> smokeParticlesToDelete{};
for (Particle* particle : m_SmokeParticles) {
particle->Update(elapsedTime);
if (particle->IsDead()) {
smokeParticlesToDelete.push_back(particle);
}
}
for (Particle* particle : smokeParticlesToDelete) {
m_SmokeParticles.erase(std::remove(m_SmokeParticles.begin(), m_SmokeParticles.end(), particle), m_SmokeParticles.end());
delete particle;
}
//check for keys
if (m_State != PlayerState::Digging) {
if (utils::isKeyDown(SDL_SCANCODE_W)) {
@@ -207,10 +296,11 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
// m_Vel.y = m_Speed / 10;
m_Acc.y += m_Speed * 10;
if (!m_IsPropellorDeployed) {
m_currentAnimation = m_flyStartAnimation;
m_flyStartAnimation->SetFlipped(m_Direction == PlayerDirection::Right);
} else {
m_currentAnimation = m_flyAnimation;
m_CurrentAnimation = m_FlyStartAnimation;
m_FlyStartAnimation->SetFlipped(m_Direction == PlayerDirection::Right);
}
else {
m_CurrentAnimation = m_FlyAnimation;
}
m_Grounded = false;
}
@@ -218,8 +308,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
if (m_Grounded) {
if (this->CanDig(Collision::Bottom, level)) {
m_DigDirection = DigDirection::Down;
m_currentAnimation = m_digStartAnimation;
m_currentAnimation->Reset();
m_CurrentAnimation = m_DigStartAnimation;
m_CurrentAnimation->Reset();
m_IsDiggingPrimed = false;
this->Dig(Collision::CollisionDirection::Bottom, level);
}
@@ -227,15 +317,15 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
}
if (utils::isKeyDown(SDL_SCANCODE_A)) {
if (!m_IsTurning) {
m_walkAnimation->SetFlipped(false);
m_flyAnimation->SetFlipped(false);
m_WalkAnimation->SetFlipped(false);
m_FlyAnimation->SetFlipped(false);
}
m_Acc.x = -m_Speed;
if (m_Direction == PlayerDirection::Right) {
m_IsTurning = true;
m_currentAnimation = m_State == PlayerState::Walking ? m_turnAnimation : m_flyTurnAnimation;
m_currentAnimation->SetFlipped(true);
m_currentAnimation->Reset();
m_CurrentAnimation = m_State == PlayerState::Walking ? m_TurnAnimation : m_FlyTurnAnimation;
m_CurrentAnimation->SetFlipped(true);
m_CurrentAnimation->Reset();
}
m_Direction = PlayerDirection::Left;
if (m_Grounded && !m_DidJustDigLeft) {
@@ -255,16 +345,16 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
if (utils::isKeyDown(SDL_SCANCODE_D)) {
if (!m_IsTurning) {
m_walkAnimation->SetFlipped(true);
m_flyAnimation->SetFlipped(true);
m_WalkAnimation->SetFlipped(true);
m_FlyAnimation->SetFlipped(true);
}
m_Acc.x = m_Speed;
if (m_Direction == PlayerDirection::Left) {
m_IsTurning = true;
m_currentAnimation = m_State == PlayerState::Walking ? m_turnAnimation : m_flyTurnAnimation;
m_currentAnimation->SetFlipped(false);
m_currentAnimation->Reset();
m_CurrentAnimation = m_State == PlayerState::Walking ? m_TurnAnimation : m_FlyTurnAnimation;
m_CurrentAnimation->SetFlipped(false);
m_CurrentAnimation->Reset();
}
m_Direction = PlayerDirection::Right;
@@ -296,37 +386,39 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
m_Acc = Vector2f { 0, 0 };
m_currentAnimation->Update(elapsedTime);
m_CurrentAnimation->Update(elapsedTime);
if (m_State == PlayerState::Flying && m_Grounded) {
m_State = PlayerState::Idle;
m_walkAnimation->SetFlipped(m_Direction == PlayerDirection::Right);
m_currentAnimation = m_walkAnimation;
m_WalkAnimation->SetFlipped(m_Direction == PlayerDirection::Right);
m_CurrentAnimation = m_WalkAnimation;
m_IsPropellorDeployed = false;
m_flyStartAnimation->Reset();
m_FlyStartAnimation->Reset();
}
if (m_currentAnimation->IsDone() && m_IsTurning) {
m_currentAnimation = m_State == PlayerState::Walking ? m_walkAnimation : m_flyAnimation;
if (m_CurrentAnimation->IsDone() && m_IsTurning) {
m_CurrentAnimation = m_State == PlayerState::Walking ? m_WalkAnimation : m_FlyAnimation;
m_IsTurning = false;
}
if(m_currentAnimation == m_flyStartAnimation) {
if(m_flyStartAnimation->IsDone()) {
if (m_CurrentAnimation == m_FlyStartAnimation) {
if (m_FlyStartAnimation->IsDone()) {
m_IsPropellorDeployed = true;
m_currentAnimation = m_flyAnimation;
} else {
m_currentAnimation = m_flyStartAnimation;
m_CurrentAnimation = m_FlyAnimation;
}
else {
m_CurrentAnimation = m_FlyStartAnimation;
}
}
if (m_currentAnimation == m_digStartAnimation) {
if (m_Direction == PlayerDirection::Left) {
m_OutletPos = m_OutLeftPos;
}
else {
m_OutletPos = m_OutRightPos;
}
#pragma region Collision
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
@@ -393,7 +485,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
}
}
Collision::CollisionRect rect = world_tile->GetCollisionRect().getCollisionRect(); //TODO: fix this mess
Collision::CollisionRect rect = world_tile->GetCollisionRect().getCollisionRect();
Collision::ResolvePlayerVsRect(*this, elapsedTime, &rect);
}
#pragma endregion
@@ -408,25 +500,35 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
}
}
switch (m_State) {
case PlayerState::Flying:
GameManager::GetInstance().DecreaseFuel(0.06f);
ChangeSound(m_FlySound);
break;
case PlayerState::Idle:
m_walkAnimation->SetPlaying(false);
m_WalkAnimation->SetPlaying(false);
GameManager::GetInstance().DecreaseFuel(0.02f);
ChangeSound(m_IdleSound);
break;
case PlayerState::Walking:
m_walkAnimation->SetPlaying(true);
m_WalkAnimation->SetPlaying(true);
GameManager::GetInstance().DecreaseFuel(0.04f);
ChangeSound(m_WalkSound);
break;
case PlayerState::Digging: {
// m_walkAnimation->SetPlaying(false);
GameManager::GetInstance().DecreaseFuel(0.06f);
ChangeSound(m_DigSound);
//Diganimation
m_currentAnimation->Update(elapsedTime);
if (m_currentAnimation->IsDone() && m_State == PlayerState::Digging && !m_IsDiggingPrimed) {
m_CurrentAnimation->Update(elapsedTime);
if (m_CurrentAnimation->IsDone() && m_State == PlayerState::Digging && !m_IsDiggingPrimed) {
m_IsDiggingPrimed = true;
m_currentAnimation = m_digAnimation;
m_CurrentAnimation = m_DigAnimation;
}
if (m_IsDiggingPrimed) {
if (!m_Digging) { //TODO: fix for setting the start position
if (!m_Digging) {
m_Digging = true;
m_DigStart = m_Position;
m_Vel = Vector2f { 0, 0 };
@@ -436,9 +538,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
//lerp to the destination
float progress = utils::map(m_DigProgress, 0.0f, m_DigTime, 0.0f, 1.0f);
int particleProgress = (int)utils::map(m_DigProgress, 0.0f, m_DigTime, 0.0f, 100.0f);
std::cout << progress << '\n';
if (particleProgress % 2 == 0) {
m_DigParticles.push_back(new Particle(m_Position + Vector2f{ 20, 0 }, Vector2f { (float)utils::randRange(-200, 200), (float)utils::randRange(-100, -300) }, 5.f,
m_DigParticles.push_back(new Particle(m_Position + Vector2f { 20, 0 }, Vector2f { (float)utils::randRange(-200, 200), (float)utils::randRange(-100, -300) },Vector2f { 0.0f, -9.81f * 20}, 5.f,
TextureManager::GetInstance()->GetTexture("particles/dirt_" + std::to_string(utils::randRange(1, 8)) + ".png")));
}
m_Position = utils::lerp(m_DigStart, m_DigDestination, progress);
@@ -449,11 +550,30 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
}
if (progress >= 1.0f) {
m_State = PlayerState::Idle;
m_currentAnimation = m_walkAnimation;
m_CurrentAnimation = m_WalkAnimation;
m_HasDeletedTile = false;
m_Digging = false;
GameManager::GetInstance().IncreaseScore(m_ToAddPoints);
m_ToAddPoints = 0;
//Add the dug item to the inventory
PlayerInventory* inventory = GameManager::GetInstance().GetInventory();
InventoryItem item = inventory->GetItemByType(m_ToAddTile);
ItemStack stack = ItemStack { item, 1 };
inventory->AddItem(stack);
std::cout << "Added: " << PlayerInventory::GetItemName(item) << std::endl;
//Print the inventory
std::cout << "-----------------------" << std::endl;
std::cout << "Inventory: " << std::endl;
std::vector<ItemStack *> items = inventory->GetItems();
for (ItemStack* i : items) {
std::cout << PlayerInventory::GetItemName(i->m_ItemType) << " Quantity: " << i->m_Quantity << std::endl;
}
std::cout << "-----------------------" << std::endl;
}
}
@@ -466,4 +586,15 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
if (m_State != PlayerState::Digging) {
m_Position = m_Position + m_Vel * elapsedTime;
}
if (m_DidSoundChange) {
m_CurrentSound->Stop();
m_DidSoundChange = false;
}
if (m_CurrentSound != nullptr) {
if (!m_CurrentSound->IsPlaying()) {
m_CurrentSound->Play(1);
}
}
}

View File

@@ -1,7 +1,9 @@
#pragma once
#include "Collision.h"
#include "SoundEffect.h"
#include "TextureManager.h"
#include "Animations/Animation.h"
#include "GridSystem/WorldTile.h"
#include "Particle/Particle.h"
class WorldLevel;
@@ -66,15 +68,23 @@ public:
m_ContactMap[dir] = tile;
}
void Die();
void ProcessImGui();
private:
void Dig(Collision::CollisionDirection dir, WorldLevel& level);
bool CanDig(Collision::CollisionDirection dir, WorldLevel& level);
void ChangeSound(SoundEffect* sound);
Vector2f m_Position;
Vector2f m_Size;
Vector2f m_OutletPos;
Vector2f m_OutLeftPos{ 55, 45};
Vector2f m_OutRightPos{ 0, 45 };
Vector2f m_Vel;
const float m_Speed{ 400.0f };
@@ -95,33 +105,54 @@ private:
WorldTile* m_DigTile{ nullptr };
int m_ToAddPoints{ 0 };
GroundTileType* m_ToAddTile{ nullptr };
bool m_IsDiggingPrimed{ false };
std::vector<Particle*> m_DigParticles{};
std::vector<Particle*> m_SmokeParticles{};
float m_SmokeTimer{ 0.0f };
const float m_SmokeTime{ 0.25f };
const float m_DigTime{ 0.5f };
bool m_IsDead{ false };
bool m_HasPlayedDeathAnimation{ false };
bool m_Grounded { false };
bool m_IsTurning{ false };
bool m_DidJustDigRight { false };
bool m_DidJustDigLeft { false };
Animation* m_currentAnimation{ nullptr };
Animation* m_walkAnimation;
Animation* m_turnAnimation{ nullptr };
Animation* m_digStartAnimation{ nullptr };
Animation* m_digAnimation{ nullptr };
Animation* m_CurrentAnimation{ nullptr };
Animation* m_WalkAnimation;
Animation* m_TurnAnimation{ nullptr };
Animation* m_DigStartAnimation{ nullptr };
Animation* m_DigAnimation{ nullptr };
Animation* m_FlyStartAnimation{ nullptr };
Animation* m_FlyAnimation{ nullptr };
Animation* m_FlyTurnAnimation{ nullptr };
Animation* m_DieStartAnimation{ nullptr };
Animation* m_DieLoopAnimation{ nullptr };
Animation* m_flyStartAnimation{ nullptr };
Animation* m_flyAnimation{ nullptr };
Animation* m_flyTurnAnimation{ nullptr };
bool m_IsPropellorDeployed{ false };
PlayerState m_State { PlayerState::Idle };
PlayerDirection m_Direction { PlayerDirection::Left };
DigDirection m_DigDirection { DigDirection::Right };
SoundEffect* m_IdleSound{ nullptr };
SoundEffect* m_WalkSound{ nullptr };
SoundEffect* m_DigSound{ nullptr };
SoundEffect* m_FlySound{ nullptr };
SoundEffect* m_CurrentSound{ nullptr };
SoundEffect* m_PrevSound{ nullptr };
bool m_DidSoundChange{ false };
//Testing
bool m_DrawCollisionRect { true };
};

View File

@@ -1,3 +1,4 @@
<a name="readme-top"></a>
<!-- GENERAL GAME INFO -->
@@ -46,13 +47,12 @@
<!-- ABOUT THE PROJECT -->
## About The Project
TODO: add screenshot
![screenshot.jpg](Assets%2Fscreenshot.jpg)
Here's why:
TODO: describe why you chose this game
* It's a classic game that I played when I was younger.
* It's a game that I can make in a reasonable amount of time.
*
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -88,21 +88,18 @@ This is an example of how to list things you need to use the software and how to
### How to run the project
Explain which project (version) must be run.
* any extra steps if required
1. Download the Repo.
2. Open the project in Visual Studio 2022 or Jetbrains Rider.
3. Run the project.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
<!-- HOW TO PLAY -->
## How to play
Use this space to show useful examples of how a game can be played.
Additional screenshots and demos work well in this space.
### Controls
* W A S D
* Mouse For menues
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -112,12 +109,34 @@ Additional screenshots and demos work well in this space.
## Class structure
### Object composition
If you applied object composition (optional); explain where and how.
#### Player
The player has a bunch of objects in the Player class, These are
- Animations
- Particles
- SoundEffects
#### WorldLevel
The world level contains all the objects for the "Main" Game. These are
- Player
- GridManager
- Background Music
- MainScreen (Game UI)
- The Sun and Moon
### Inheritance
Explain where you applied inheritance (mandatory).
Here are a couple examples on how i used Inheritance throughout the project.
#### Screens
The Screen class is the base class for all the screens in the game. <br>
This Class manages all the GuiElements inside of it. <br>
Also all the subscreens, eg. FuelScreen, SellScreen, even the Main Game ui is a subclass of the Screen type.
#### GuiElement
The whole Screen system is based on the GuiElement. This class has a Draw and Update Function. <br>
This is because the Screen class calls these for each of the subclasses of a GuiElement. <br>
For Example, the Button class is a subclass of GuiElement. <br>
The Button class has a Draw and Update function that the Screen class calls. The screen does not know what type of <br>
update it's calling, it just knows that it's calling the update function of a GuiElement.
### ..
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -127,18 +146,15 @@ Explain where you applied inheritance (mandatory).
- [x] Accept / set up github project
- [x] week 01 topics applied
- [ ] const keyword applied proactively (variables, functions,..)
- [ ] static keyword applied proactively (class variables, static functions,..)
- [ ] object composition (optional)
- [x] week 02 topics applied
- [x] week 03 topics applied
- [ ] week 04 topics applied
- [ ] week 05 topics applied
- [ ] week 06 topics applied
- [ ] week 07 topics applied
- [ ] week 08 topics applied
- [ ] week 09 topics applied (optional)
- [ ] week 10 topics applied (optional)
- [x] week 04 topics applied
- [x] week 05 topics applied
- [x] week 06 topics applied
- [x] week 07 topics applied
- [x] week 08 topics applied
- [x] week 09 topics applied (optional)
- [x] week 10 topics applied (optional)
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -148,6 +164,7 @@ Explain where you applied inheritance (mandatory).
Bram Verhulst - bram.verhulst@student.howest.be
Project Link: [Here](https://github.com/HowestDAE/dae16-VerhulstBram)
Alternative Project Link (Gitea): [Here](https://git.brammie15.dev/brammie15/dae16-VerhulstBram-GameProject)
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -158,7 +175,6 @@ Project Link: [Here](https://github.com/HowestDAE/dae16-VerhulstBram)
Use this space to list resources you find helpful and would like to give credit to.
* [Example 1: cpp reference on std::vector](https://en.cppreference.com/w/cpp/container/vector)
* ..
* [Dear ImGui for development](https://github.com/ocornut/imgui)
<p align="right">(<a href="#readme-top">back to top</a>)</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
Resources/gui/main/help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
Resources/gui/main/inv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

BIN
Resources/sound/bgm.wav Normal file

Binary file not shown.

BIN
Resources/sound/buy.wav Normal file

Binary file not shown.

BIN
Resources/sound/drill.wav Normal file

Binary file not shown.

BIN
Resources/sound/fly.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
Resources/sound/idle.wav Normal file

Binary file not shown.

BIN
Resources/sound/walk.wav Normal file

Binary file not shown.