Compare commits
15 Commits
b406c8ffcc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c83e566dd | ||
|
|
8866f33c09 | ||
|
|
600050c198 | ||
|
|
d5c002c2b2 | ||
|
|
8c3a485c2d | ||
|
|
d3b932df22 | ||
|
|
77784a167e | ||
|
|
b6be73019f | ||
|
|
64915567dc | ||
|
|
a1a2406084 | ||
|
|
8d56c747be | ||
|
|
da8377e7a0 | ||
|
|
8a1506d42f | ||
|
|
b50a2d6fc0 | ||
|
|
f5d352239c |
5
.gitignore
vendored
@@ -400,3 +400,8 @@ FodyWeavers.xsd
|
|||||||
# Game Project specifics -> do not ignore:
|
# Game Project specifics -> do not ignore:
|
||||||
!**/Libraries/**/x86/
|
!**/Libraries/**/x86/
|
||||||
!**/Libraries/**/x64/
|
!**/Libraries/**/x64/
|
||||||
|
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
.idea/*
|
||||||
|
.idea/workspace.xml
|
||||||
|
|||||||
204
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -11,33 +11,16 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/Game/GroundTileTypeManager.cpp" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/Game/Levels/World/OrbitingObject.cpp" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/Game/GroundTileTypeManager.h" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/Game/Levels/World/OrbitingObject.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$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Engine/Text.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Text.cpp" 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/Game.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.cpp" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj.filters" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj.filters" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Game/GameManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GameManager.cpp" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Game/GameManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GameManager.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" 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/Gui/Screens/MainScreen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.h" 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/Screen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screen.cpp" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.cpp" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.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/MainMenu/MainMenuLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/MainMenu/MainMenuLevel.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/WorldLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" 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/Levels/World/WorldLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.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$/Game/TextureManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.cpp" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Game/TextureManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.h" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Game/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/main.cpp" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -47,19 +30,34 @@
|
|||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
<map>
|
<map>
|
||||||
<entry key="$PROJECT_DIR$" value="ebda39f690147cf0dfe51c6e4e121c4f1e3606e8" />
|
<entry key="$PROJECT_DIR$" value="d3b932df22970cf2f14e9dd79721ccae1d938a38" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
|
<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/type_traits" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/vector" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/vector" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Animations/Animation.cpp" 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$/Game/Animations/Animation.h" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Engine/BaseGame.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Engine/BaseGame.h" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Engine/Texture.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<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/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Gui/Screens/FuelScreen.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Levels/World/Building.cpp" root0="SKIP_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/pch.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$/Game/pch.h" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Libraries/SDLMain/SDL2-2.26.3/include/SDL.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Libraries/SDLMain/SDL2-2.26.3/include/SDL_gamecontroller.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../week6/Lab/Lab6/Game.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../week6/Lab/Lab6/Game.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../week6/Lab/Lab6/main.cpp" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../week6/Lab/Lab6/main.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../week6/Lab/Lab6/pch.h" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../week6/Lab/Lab6/pch.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
@@ -80,28 +78,28 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"C++ Project.Game.executor": "Debug",
|
"C++ Project.Game.executor": "Debug",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"rider.external.source.directories": [
|
"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\\DecompilerCache",
|
||||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||||
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
<configuration name="Game" type="CppProject" factoryName="C++ Project">
|
<configuration name="Game" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1>
|
<configuration_1>
|
||||||
@@ -226,7 +224,33 @@
|
|||||||
<workItem from="1713817523511" duration="347000" />
|
<workItem from="1713817523511" duration="347000" />
|
||||||
<workItem from="1713853942608" duration="1816000" />
|
<workItem from="1713853942608" duration="1816000" />
|
||||||
<workItem from="1713855878621" duration="24000" />
|
<workItem from="1713855878621" duration="24000" />
|
||||||
<workItem from="1713858589244" duration="4723000" />
|
<workItem from="1713858589244" duration="8169000" />
|
||||||
|
<workItem from="1713888717170" duration="3930000" />
|
||||||
|
<workItem from="1713982171548" duration="3263000" />
|
||||||
|
<workItem from="1713995813246" duration="2567000" />
|
||||||
|
<workItem from="1714026889126" duration="4211000" />
|
||||||
|
<workItem from="1714046400732" duration="2462000" />
|
||||||
|
<workItem from="1714372163827" duration="2962000" />
|
||||||
|
<workItem from="1714459066696" duration="21789000" />
|
||||||
|
<workItem from="1714640485259" duration="321000" />
|
||||||
|
<workItem from="1714641751956" duration="3705000" />
|
||||||
|
<workItem from="1714652168988" duration="1613000" />
|
||||||
|
<workItem from="1714653831106" duration="2710000" />
|
||||||
|
<workItem from="1714763594789" duration="1983000" />
|
||||||
|
<workItem from="1714824060444" duration="811000" />
|
||||||
|
<workItem from="1715031948901" duration="46000" />
|
||||||
|
<workItem from="1715063584283" duration="11702000" />
|
||||||
|
<workItem from="1715170674144" duration="2320000" />
|
||||||
|
<workItem from="1715206284291" duration="5406000" />
|
||||||
|
<workItem from="1715254613428" duration="3973000" />
|
||||||
|
<workItem from="1715293126957" duration="547000" />
|
||||||
|
<workItem from="1715334251448" duration="4485000" />
|
||||||
|
<workItem from="1715360147026" duration="5634000" />
|
||||||
|
<workItem from="1715583954732" duration="5283000" />
|
||||||
|
<workItem from="1715669033601" duration="11720000" />
|
||||||
|
<workItem from="1715762731245" duration="3986000" />
|
||||||
|
<workItem from="1715773968873" duration="3580000" />
|
||||||
|
<workItem from="1715814533138" duration="12142000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@@ -308,7 +332,79 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1713738730939</updated>
|
<updated>1713738730939</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="11" />
|
<task id="LOCAL-00011" summary="Add alot of memory leak fixes">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1713863838768</created>
|
||||||
|
<option name="number" value="00011" />
|
||||||
|
<option name="presentableId" value="LOCAL-00011" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1713863838768</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00012" summary="Add fps">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1714460546894</created>
|
||||||
|
<option name="number" value="00012" />
|
||||||
|
<option name="presentableId" value="LOCAL-00012" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1714460546894</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00013" summary="Add player turning (Finally)">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1714471045905</created>
|
||||||
|
<option name="number" value="00013" />
|
||||||
|
<option name="presentableId" value="LOCAL-00013" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1714471045905</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00014" summary="Update gitignore">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1714471502013</created>
|
||||||
|
<option name="number" value="00014" />
|
||||||
|
<option name="presentableId" value="LOCAL-00014" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1714471502013</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00015" summary="Remove All Memory leaks">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1714654669410</created>
|
||||||
|
<option name="number" value="00015" />
|
||||||
|
<option name="presentableId" value="LOCAL-00015" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1714654669410</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00016" summary="Fix digging">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1715070920513</created>
|
||||||
|
<option name="number" value="00016" />
|
||||||
|
<option name="presentableId" value="LOCAL-00016" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1715070920513</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00017" summary="Started on GuiIcon, General fixes">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1715208368790</created>
|
||||||
|
<option name="number" value="00017" />
|
||||||
|
<option name="presentableId" value="LOCAL-00017" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1715208368790</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00018" summary="Add Particles (basic)">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1715255455692</created>
|
||||||
|
<option name="number" value="00018" />
|
||||||
|
<option name="presentableId" value="LOCAL-00018" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1715255455692</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00019" summary="Add Text rendering and Hull / Fuel Meters">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1715817878533</created>
|
||||||
|
<option name="number" value="00019" />
|
||||||
|
<option name="presentableId" value="LOCAL-00019" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1715817878533</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="20" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -326,9 +422,17 @@
|
|||||||
<MESSAGE value="Fixed sidePieces (Need to add more cases tho)" />
|
<MESSAGE value="Fixed sidePieces (Need to add more cases tho)" />
|
||||||
<MESSAGE value="Pre Point2f Nuke Fixed drawing, Added general optimisations" />
|
<MESSAGE value="Pre Point2f Nuke Fixed drawing, Added general optimisations" />
|
||||||
<MESSAGE value="Remove Point2f, replace with Vector2f" />
|
<MESSAGE value="Remove Point2f, replace with Vector2f" />
|
||||||
<MESSAGE value="Fix digging" />
|
|
||||||
<MESSAGE value="Added Buildings Fixed rendering bugs with edges" />
|
<MESSAGE value="Added Buildings Fixed rendering bugs with edges" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Added Buildings Fixed rendering bugs with edges" />
|
<MESSAGE value="Add alot of memory leak fixes" />
|
||||||
|
<MESSAGE value="Add fps" />
|
||||||
|
<MESSAGE value="Add player turning (Finally)" />
|
||||||
|
<MESSAGE value="Update gitignore" />
|
||||||
|
<MESSAGE value="Remove All Memory leaks" />
|
||||||
|
<MESSAGE value="Fix digging" />
|
||||||
|
<MESSAGE value="Started on GuiIcon, General fixes" />
|
||||||
|
<MESSAGE value="Add Particles (basic)" />
|
||||||
|
<MESSAGE value="Add Text rendering and Hull / Fuel Meters" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Add Text rendering and Hull / Fuel Meters" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|||||||
15
.idea/.idea.Prog2Engine/.idea/.gitignore
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Rider ignored files
|
|
||||||
/modules.xml
|
|
||||||
/projectSettingsUpdater.xml
|
|
||||||
/contentModel.xml
|
|
||||||
/.idea.Prog2Engine.iml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# GitHub Copilot persisted chat sessions
|
|
||||||
/copilot/chatSessions
|
|
||||||
1
.idea/.idea.Prog2Engine/.idea/.name
generated
@@ -1 +0,0 @@
|
|||||||
Prog2Engine
|
|
||||||
4
.idea/.idea.Prog2Engine/.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
|
||||||
</project>
|
|
||||||
8
.idea/.idea.Prog2Engine/.idea/indexLayout.xml
generated
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="UserContentModel">
|
|
||||||
<attachedFolders />
|
|
||||||
<explicitIncludes />
|
|
||||||
<explicitExcludes />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
.idea/.idea.Prog2Engine/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
BIN
Assets/Player/PlayerDig.aseprite
Normal file
BIN
Assets/Player/PlayerDigStart.aseprite
Normal file
BIN
Assets/Player/PlayerTurn.aseprite
Normal file
@@ -40,7 +40,7 @@ void BaseGame::InitializeGameEngine()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize SDL
|
// Initialize SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO /*| SDL_INIT_AUDIO*/) < 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC /*| SDL_INIT_AUDIO*/) < 0)
|
||||||
{
|
{
|
||||||
std::cerr << "BaseGame::Initialize( ), error when calling SDL_Init: " << SDL_GetError() << std::endl;
|
std::cerr << "BaseGame::Initialize( ), error when calling SDL_Init: " << SDL_GetError() << std::endl;
|
||||||
return;
|
return;
|
||||||
@@ -107,7 +107,7 @@ void BaseGame::InitializeGameEngine()
|
|||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
// ImGui::StyleColorsLight();
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForOpenGL(m_pWindow, m_pContext);
|
ImGui_ImplSDL2_InitForOpenGL(m_pWindow, m_pContext);
|
||||||
@@ -146,6 +146,31 @@ void BaseGame::InitializeGameEngine()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pIcon = IMG_Load("icon.png");
|
||||||
|
SDL_SetWindowIcon(m_pWindow, m_pIcon);
|
||||||
|
|
||||||
|
// delete icon;
|
||||||
|
|
||||||
|
//Initialize controller
|
||||||
|
m_pGameController = nullptr;
|
||||||
|
if (SDL_NumJoysticks() < 1)
|
||||||
|
{
|
||||||
|
std::cout << "Warning: No controller connected!" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Load joystick
|
||||||
|
m_pGameController = SDL_GameControllerOpen(0);
|
||||||
|
if (m_pGameController == nullptr)
|
||||||
|
{
|
||||||
|
std::cout << "Warning: Unable to open game controller! SDL Error: " << SDL_GetError() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt");
|
||||||
|
|
||||||
|
SDL_RendererInfo m_RendererInfo;
|
||||||
|
SDL_GetRendererInfo(SDL_GetRenderer(m_pWindow), &m_RendererInfo);
|
||||||
|
|
||||||
m_Initialized = true;
|
m_Initialized = true;
|
||||||
}
|
}
|
||||||
@@ -200,6 +225,12 @@ void BaseGame::Run()
|
|||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
this->ProcessMouseWheelEvent(e.wheel);
|
this->ProcessMouseWheelEvent(e.wheel);
|
||||||
break;
|
break;
|
||||||
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
|
std::cout << "Button " << int(e.jbutton.button) << " down on controller " << int(e.jbutton.which) << std::endl;
|
||||||
|
if(e.cbutton.button == SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_X) {
|
||||||
|
std::cout << "X button pressed" << std::endl;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,6 +276,8 @@ void BaseGame::CleanupGameEngine()
|
|||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
SDL_FreeSurface(m_pIcon);
|
||||||
|
|
||||||
SDL_GL_DeleteContext(m_pContext);
|
SDL_GL_DeleteContext(m_pContext);
|
||||||
|
|
||||||
SDL_DestroyWindow(m_pWindow);
|
SDL_DestroyWindow(m_pWindow);
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ private:
|
|||||||
// Prevent timing jumps when debugging
|
// Prevent timing jumps when debugging
|
||||||
const float m_MaxElapsedSeconds;
|
const float m_MaxElapsedSeconds;
|
||||||
|
|
||||||
|
SDL_GameController* m_pGameController;
|
||||||
|
|
||||||
|
SDL_Surface* m_pIcon;
|
||||||
|
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
void InitializeGameEngine();
|
void InitializeGameEngine();
|
||||||
void CleanupGameEngine();
|
void CleanupGameEngine();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
Text::Text(const std::string& text, const std::string& fontPath, int size, const Color4f& color): m_Text(text), m_FontPath(fontPath), m_Color(color) {
|
Text::Text(const std::string& text, const std::string& fontPath, int size, const Color4f& color): m_Text(text), m_FontPath(fontPath), m_Size(size), m_Color(color) {
|
||||||
m_Texture = new Texture(text, fontPath, size, color);
|
m_Texture = new Texture(text, fontPath, size, color);
|
||||||
m_IsCreatedOk = m_Texture->IsCreationOk();
|
m_IsCreatedOk = m_Texture->IsCreationOk();
|
||||||
if(!m_IsCreatedOk) {
|
if(!m_IsCreatedOk) {
|
||||||
@@ -14,5 +14,17 @@ Text::~Text() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Text::Draw(const Vector2f& pos) const {
|
void Text::Draw(const Vector2f& pos) const {
|
||||||
|
if(m_IsCreatedOk) {
|
||||||
m_Texture->Draw(pos);
|
m_Texture->Draw(pos);
|
||||||
|
} else {
|
||||||
|
std::cout << "Trying to render a Text that is not correctly made,\nText: " << m_Text << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Text::ChangeText(const std::string& text) {
|
||||||
|
if(m_IsCreatedOk && m_Texture->IsCreationOk()) {
|
||||||
|
delete m_Texture;
|
||||||
|
m_Texture = new Texture(text, m_FontPath, m_Size, m_Color);
|
||||||
|
} else {
|
||||||
|
std::cout << "This is wierd??: " << m_Text << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,14 @@ public:
|
|||||||
|
|
||||||
void Draw(const Vector2f& pos) const;
|
void Draw(const Vector2f& pos) const;
|
||||||
|
|
||||||
|
void ChangeText(const std::string& text);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_Text;
|
std::string m_Text;
|
||||||
std::string m_FontPath;
|
std::string m_FontPath;
|
||||||
|
int m_Size;
|
||||||
Color4f m_Color;
|
Color4f m_Color;
|
||||||
Texture* m_Texture;
|
Texture* m_Texture;
|
||||||
bool m_IsCreatedOk{ false };
|
bool m_IsCreatedOk{ false };
|
||||||
|
|||||||
@@ -692,6 +692,12 @@ float utils::map(float value, float start1, float stop1, float start2, float sto
|
|||||||
float newVal = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
|
float newVal = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
|
||||||
return newVal;
|
return newVal;
|
||||||
}
|
}
|
||||||
|
float utils::clamp(float value, float min, float max) {
|
||||||
|
return std::max(min, std::min(value, max));
|
||||||
|
}
|
||||||
|
Vector2f utils::clamp(const Vector2f& value, const Vector2f& min, const Vector2f& max) {
|
||||||
|
return Vector2f { clamp(value.x, min.x, max.x), clamp(value.y, min.y, max.y) };
|
||||||
|
}
|
||||||
bool utils::isKeyDown(int keycode) {
|
bool utils::isKeyDown(int keycode) {
|
||||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||||
if (pStates != nullptr) {
|
if (pStates != nullptr) {
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ namespace utils
|
|||||||
Vector2f lerp(const Vector2f& a, const Vector2f& b, float t);
|
Vector2f lerp(const Vector2f& a, const Vector2f& b, float t);
|
||||||
|
|
||||||
float map(float value, float start1, float stop1, float start2, float stop2);
|
float map(float value, float start1, float stop1, float start2, float stop2);
|
||||||
|
|
||||||
|
float clamp(float value, float min, float max);
|
||||||
|
Vector2f clamp(const Vector2f& value, const Vector2f& min, const Vector2f& max);
|
||||||
#pragma endregion CollisionFunctionality
|
#pragma endregion CollisionFunctionality
|
||||||
|
|
||||||
bool isKeyDown(SDL_Keycode keycode);
|
bool isKeyDown(SDL_Keycode keycode);
|
||||||
|
|||||||
@@ -1,24 +1,31 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "Animation.h"
|
#include "Animation.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames) {
|
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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
void Animation::Update(float elapsedSec) {
|
void Animation::Update(float elapsedSec) {
|
||||||
if (m_isPlaying) {
|
if (m_isPlaying) {
|
||||||
m_FrameTimer -= elapsedSec;
|
m_FrameTimer -= elapsedSec;
|
||||||
if (m_FrameTimer <= 0.0f) {
|
if (m_FrameTimer <= 0.0f) {
|
||||||
m_FrameTimer = 0.1f;
|
m_FrameTimer = m_FrameDuration;
|
||||||
++m_CurrentFrame;
|
++m_CurrentFrame;
|
||||||
if (m_CurrentFrame >= m_Frames) {
|
if (m_CurrentFrame >= m_Frames) {
|
||||||
m_CurrentFrame = 0;
|
m_CurrentFrame = 0;
|
||||||
|
if (!m_isLooping) {
|
||||||
|
m_hasPlayedOnce = true;
|
||||||
|
m_isPlaying = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Animation::Draw(const Vector2f& pos) const {
|
void Animation::Draw(const Vector2f& pos) const {
|
||||||
Draw(pos, Rectf{ pos.x, pos.y, m_SrcRect.width, m_SrcRect.height });
|
Draw(pos, Rectf { pos.x, pos.y, m_SrcRect.width, m_SrcRect.height });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
|
void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
|
||||||
@@ -27,3 +34,24 @@ void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
|
|||||||
|
|
||||||
m_pTexture->Draw(dst, src, m_isFlipped);
|
m_pTexture->Draw(dst, src, m_isFlipped);
|
||||||
}
|
}
|
||||||
|
void Animation::SetPlaying(bool isPlaying) {
|
||||||
|
m_isPlaying = isPlaying;
|
||||||
|
}
|
||||||
|
void Animation::SetFlipped(bool isFlipped) {
|
||||||
|
m_isFlipped = isFlipped;
|
||||||
|
}
|
||||||
|
void Animation::Reset() {
|
||||||
|
m_CurrentFrame = 0;
|
||||||
|
m_hasPlayedOnce = false;
|
||||||
|
m_isPlaying = true;
|
||||||
|
m_FrameTimer = m_FrameDuration;
|
||||||
|
}
|
||||||
|
bool Animation::IsDone() const {
|
||||||
|
return m_hasPlayedOnce && !m_isLooping;
|
||||||
|
}
|
||||||
|
int Animation::GetFrameCount() const {
|
||||||
|
return m_Frames;
|
||||||
|
}
|
||||||
|
void Animation::SetFrame(int frame) {
|
||||||
|
m_CurrentFrame = frame;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,19 +4,21 @@
|
|||||||
class Animation
|
class Animation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect);
|
Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping = true);
|
||||||
~Animation() = default;
|
|
||||||
|
|
||||||
void Update(float elapsedSec);
|
void Update(float elapsedSec);
|
||||||
void Draw(const Vector2f& pos) const;
|
void Draw(const Vector2f& pos) const;
|
||||||
void Draw(const Vector2f& pos, const Rectf& dst) const;
|
void Draw(const Vector2f& pos, const Rectf& dst) const;
|
||||||
|
|
||||||
void SetPlaying(bool isPlaying) {
|
|
||||||
m_isPlaying = isPlaying;
|
void SetPlaying(bool isPlaying);
|
||||||
}
|
void SetFlipped(bool isFlipped);
|
||||||
void SetFlipped(bool isFlipped) {
|
|
||||||
m_isFlipped = isFlipped;
|
void Reset();
|
||||||
}
|
bool IsDone() const;
|
||||||
|
|
||||||
|
int GetFrameCount() const;
|
||||||
|
void SetFrame(int frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Texture* m_pTexture;
|
Texture* m_pTexture;
|
||||||
@@ -26,6 +28,11 @@ private:
|
|||||||
int m_CurrentFrame { 0 };
|
int m_CurrentFrame { 0 };
|
||||||
float m_FrameTimer { 0.0f };
|
float m_FrameTimer { 0.0f };
|
||||||
|
|
||||||
|
float m_FrameDuration { 0.1f };
|
||||||
|
|
||||||
bool m_isPlaying { true };
|
bool m_isPlaying { true };
|
||||||
bool m_isFlipped { false };
|
bool m_isFlipped { false };
|
||||||
|
|
||||||
|
bool m_isLooping { true };
|
||||||
|
bool m_hasPlayedOnce { false };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
#include "GridSystem/GroundTileTypeManager.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "GridSystem/WorldTile.h"
|
||||||
#include "Levels/World/WorldLevel.h"
|
#include "Levels/World/WorldLevel.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -28,8 +30,8 @@ void Game::Initialize() {
|
|||||||
|
|
||||||
void Game::Cleanup() {
|
void Game::Cleanup() {
|
||||||
|
|
||||||
//TODO: ask how 2 delete the TextureManager
|
|
||||||
ScreenManager::DestroyInstance();
|
ScreenManager::DestroyInstance();
|
||||||
|
GroundTileTypeManager::DestroyInstance();
|
||||||
TextureManager::DestroyInstance();
|
TextureManager::DestroyInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@ void Game::Update(float elapsedSec) {
|
|||||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||||
|
|
||||||
if (m_IsRightMouseDown) {
|
if (m_IsRightMouseDown) {
|
||||||
const Vector2f newCameraPos = Vector2f { m_MousePos.x + m_MouseOffset.x, m_MousePos.y + m_MouseOffset.y };
|
const Vector2f newCameraPos = Vector2f { m_MousePosition.x + m_MouseOffset.x, m_MousePosition.y + m_MouseOffset.y };
|
||||||
m_Camera.SetPosition(Vector2f { -newCameraPos.x, -newCameraPos.y });
|
m_Camera.SetPosition(Vector2f { -newCameraPos.x, -newCameraPos.y });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -55,49 +57,28 @@ void Game::Draw() const {
|
|||||||
|
|
||||||
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
|
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
|
||||||
//std::cout << "KEYDOWN event: " << e.keysym.sym << std::endl;
|
//std::cout << "KEYDOWN event: " << e.keysym.sym << std::endl;
|
||||||
|
if(e.keysym.sym == SDLK_BACKQUOTE) {
|
||||||
|
m_imGui = !m_imGui;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
|
void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
||||||
m_MousePos = Vector2f { float(e.x), float(e.y) };
|
m_MousePosition = Vector2f { float(e.x), float(e.y) };
|
||||||
m_pCurrentLevel->MouseMove(Vector2f { float(e.x), float(e.y) });
|
m_pCurrentLevel->MouseMove(Vector2f { float(e.x), float(e.y) });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
||||||
m_IsRightMouseDown = e.button == SDL_BUTTON_RIGHT;
|
m_IsRightMouseDown = e.button == SDL_BUTTON_RIGHT;
|
||||||
m_MouseOffset = Vector2f { -m_Camera.GetPosition().x - m_MousePos.x, -m_Camera.GetPosition().y - m_MousePos.y };
|
m_MouseOffset = Vector2f { -m_Camera.GetPosition().x - m_MousePosition.x, -m_Camera.GetPosition().y - m_MousePosition.y };
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
||||||
m_IsRightMouseDown = e.button == SDL_BUTTON_RIGHT ? false : m_IsRightMouseDown;
|
m_IsRightMouseDown = e.button == SDL_BUTTON_RIGHT ? false : m_IsRightMouseDown;
|
||||||
//std::cout << "MOUSEBUTTONUP event: ";
|
|
||||||
//switch ( e.button )
|
|
||||||
//{
|
|
||||||
//case SDL_BUTTON_LEFT:
|
|
||||||
// std::cout << " left button " << std::endl;
|
|
||||||
// break;
|
|
||||||
//case SDL_BUTTON_RIGHT:k
|
|
||||||
// std::cout << " right button " << std::endl;
|
|
||||||
// break;
|
|
||||||
//case SDL_BUTTON_MIDDLE:
|
|
||||||
// std::cout << " middle button " << std::endl;
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
void Game::ProcessMouseWheelEvent(const SDL_MouseWheelEvent& e) {
|
void Game::ProcessMouseWheelEvent(const SDL_MouseWheelEvent& e) {
|
||||||
Vector2f scroll = Vector2f { 0, 0 };
|
|
||||||
if (e.y > 0) {
|
|
||||||
scroll = Vector2f { 0, 1 };
|
|
||||||
}
|
|
||||||
else if (e.y < 0) {
|
|
||||||
scroll = Vector2f { 0, -1 };
|
|
||||||
}
|
|
||||||
//camera zoom
|
|
||||||
float newScale = m_Camera.GetScale() - e.preciseY * 0.1f;
|
float newScale = m_Camera.GetScale() - e.preciseY * 0.1f;
|
||||||
if(newScale < 0.0f) {
|
if(newScale < 0.0f) {
|
||||||
newScale = 0.0f;
|
newScale = 0.0f;
|
||||||
@@ -105,5 +86,7 @@ void Game::ProcessMouseWheelEvent(const SDL_MouseWheelEvent& e) {
|
|||||||
m_Camera.SetScale(newScale);
|
m_Camera.SetScale(newScale);
|
||||||
}
|
}
|
||||||
void Game::ProcessImGui() {
|
void Game::ProcessImGui() {
|
||||||
|
if(m_imGui) {
|
||||||
m_pCurrentLevel->ProcessImGui();
|
m_pCurrentLevel->ProcessImGui();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ public:
|
|||||||
static Rectf VIEWPORT;
|
static Rectf VIEWPORT;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// FUNCTIONS
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
@@ -43,8 +42,11 @@ private:
|
|||||||
|
|
||||||
Level* m_pCurrentLevel;
|
Level* m_pCurrentLevel;
|
||||||
|
|
||||||
Vector2f m_MousePos {};
|
Vector2f m_MousePosition {};
|
||||||
Vector2f m_MouseOffset {};
|
Vector2f m_MouseOffset {};
|
||||||
bool m_IsRightMouseDown {};
|
bool m_IsRightMouseDown {};
|
||||||
|
|
||||||
|
|
||||||
|
bool m_imGui{ true };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<IncludePath>C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Game;C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Engine\imgui;$(SolutionDir)\Libraries\SDLTtf\SDL2_ttf-2.20.2\include;$(SolutionDir)\Libraries\SDLMixer\SDL2_mixer-2.6.3\include;$(SolutionDir)\Libraries\SDLImage\SDL2_image-2.6.3\include;$(SolutionDir)\Libraries\SDLMain\SDL2-2.26.3\include;$(SolutionDir)\Engine;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)Game;$(SolutionDir)Engine\imgui;$(SolutionDir)\Libraries\SDLTtf\SDL2_ttf-2.20.2\include;$(SolutionDir)\Libraries\SDLMixer\SDL2_mixer-2.6.3\include;$(SolutionDir)\Libraries\SDLImage\SDL2_image-2.6.3\include;$(SolutionDir)\Libraries\SDLMain\SDL2-2.26.3\include;$(SolutionDir)\Engine;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(SolutionDir)\x64\Debug;$(SolutionDir)\Libraries\SDLTtf\SDL2_ttf-2.20.2\lib\x64;$(SolutionDir)\Libraries\SDLMixer\SDL2_mixer-2.6.3\lib\x64;$(SolutionDir)\Libraries\SDLImage\SDL2_image-2.6.3\lib\x64;$(SolutionDir)\Libraries\SDLMain\SDL2-2.26.3\lib\x64;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)\x64\Debug;$(SolutionDir)\Libraries\SDLTtf\SDL2_ttf-2.20.2\lib\x64;$(SolutionDir)\Libraries\SDLMixer\SDL2_mixer-2.6.3\lib\x64;$(SolutionDir)\Libraries\SDLImage\SDL2_image-2.6.3\lib\x64;$(SolutionDir)\Libraries\SDLMain\SDL2-2.26.3\lib\x64;$(LibraryPath)</LibraryPath>
|
||||||
<CustomBuildAfterTargets>BuildCompile</CustomBuildAfterTargets>
|
<CustomBuildAfterTargets>BuildCompile</CustomBuildAfterTargets>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -112,6 +112,7 @@
|
|||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
<BrowseInformation>true</BrowseInformation>
|
<BrowseInformation>true</BrowseInformation>
|
||||||
|
<LanguageStandard>Default</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@@ -156,6 +157,80 @@
|
|||||||
<ClCompile Include="Camera.cpp" />
|
<ClCompile Include="Camera.cpp" />
|
||||||
<ClCompile Include="Game.cpp" />
|
<ClCompile Include="Game.cpp" />
|
||||||
<ClCompile Include="GameManager.cpp" />
|
<ClCompile Include="GameManager.cpp" />
|
||||||
|
<ClCompile Include="GridSystem\GroundTileTypeManager.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="GridSystem\WorldGridManager.cpp">
|
<ClCompile Include="GridSystem\WorldGridManager.cpp">
|
||||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@@ -306,10 +381,86 @@
|
|||||||
<LinkCompiled>true</LinkCompiled>
|
<LinkCompiled>true</LinkCompiled>
|
||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</BrowseInformation>
|
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</BrowseInformation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="GroundTileTypeManager.cpp" />
|
<ClCompile Include="Gui\GuiButton.cpp" />
|
||||||
<ClCompile Include="Gui\Button.cpp" />
|
<ClCompile Include="Gui\GuiElement.cpp" />
|
||||||
|
<ClCompile Include="Gui\GuiMeter.cpp" />
|
||||||
|
<ClCompile Include="Gui\GuiText.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\Screen.cpp" />
|
<ClCompile Include="Gui\Screen.cpp" />
|
||||||
<ClCompile Include="Gui\Screens\FuelScreen.cpp" />
|
<ClCompile Include="Gui\Screens\FuelScreen.cpp" />
|
||||||
|
<ClCompile Include="Gui\Screens\MainScreen.cpp" />
|
||||||
<ClCompile Include="Gui\Screens\ScreenManager.cpp" />
|
<ClCompile Include="Gui\Screens\ScreenManager.cpp" />
|
||||||
<ClCompile Include="Levels\Level.cpp">
|
<ClCompile Include="Levels\Level.cpp">
|
||||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||||
@@ -388,6 +539,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Levels\MainMenu\MainMenuLevel.cpp" />
|
<ClCompile Include="Levels\MainMenu\MainMenuLevel.cpp" />
|
||||||
<ClCompile Include="Levels\World\Building.cpp" />
|
<ClCompile Include="Levels\World\Building.cpp" />
|
||||||
|
<ClCompile Include="Levels\World\OrbitingObject.cpp" />
|
||||||
<ClCompile Include="Levels\World\WorldLevel.cpp">
|
<ClCompile Include="Levels\World\WorldLevel.cpp">
|
||||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@@ -464,6 +616,7 @@
|
|||||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</BrowseInformation>
|
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</BrowseInformation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="Particle\Particle.cpp" />
|
||||||
<ClCompile Include="pch.cpp" />
|
<ClCompile Include="pch.cpp" />
|
||||||
<ClCompile Include="Player.cpp" />
|
<ClCompile Include="Player.cpp" />
|
||||||
<ClCompile Include="TextureManager.cpp" />
|
<ClCompile Include="TextureManager.cpp" />
|
||||||
@@ -473,17 +626,23 @@
|
|||||||
<ClInclude Include="Camera.h" />
|
<ClInclude Include="Camera.h" />
|
||||||
<ClInclude Include="Game.h" />
|
<ClInclude Include="Game.h" />
|
||||||
<ClInclude Include="GameManager.h" />
|
<ClInclude Include="GameManager.h" />
|
||||||
|
<ClInclude Include="GridSystem\GroundTileTypeManager.h" />
|
||||||
<ClInclude Include="GridSystem\WorldGridManager.h" />
|
<ClInclude Include="GridSystem\WorldGridManager.h" />
|
||||||
<ClInclude Include="GridSystem\WorldTile.h" />
|
<ClInclude Include="GridSystem\WorldTile.h" />
|
||||||
<ClInclude Include="GroundTileTypeManager.h" />
|
<ClInclude Include="Gui\GuiButton.h" />
|
||||||
<ClInclude Include="Gui\Button.h" />
|
<ClInclude Include="Gui\GuiElement.h" />
|
||||||
|
<ClInclude Include="Gui\GuiMeter.h" />
|
||||||
|
<ClInclude Include="Gui\GuiText.h" />
|
||||||
<ClInclude Include="Gui\Screen.h" />
|
<ClInclude Include="Gui\Screen.h" />
|
||||||
<ClInclude Include="Gui\Screens\FuelScreen.h" />
|
<ClInclude Include="Gui\Screens\FuelScreen.h" />
|
||||||
|
<ClInclude Include="Gui\Screens\MainScreen.h" />
|
||||||
<ClInclude Include="Gui\Screens\ScreenManager.h" />
|
<ClInclude Include="Gui\Screens\ScreenManager.h" />
|
||||||
<ClInclude Include="Levels\Level.h" />
|
<ClInclude Include="Levels\Level.h" />
|
||||||
<ClInclude Include="Levels\MainMenu\MainMenuLevel.h" />
|
<ClInclude Include="Levels\MainMenu\MainMenuLevel.h" />
|
||||||
<ClInclude Include="Levels\World\Building.h" />
|
<ClInclude Include="Levels\World\Building.h" />
|
||||||
|
<ClInclude Include="Levels\World\OrbitingObject.h" />
|
||||||
<ClInclude Include="Levels\World\WorldLevel.h" />
|
<ClInclude Include="Levels\World\WorldLevel.h" />
|
||||||
|
<ClInclude Include="Particle\Particle.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="Player.h" />
|
<ClInclude Include="Player.h" />
|
||||||
<ClInclude Include="TextureManager.h" />
|
<ClInclude Include="TextureManager.h" />
|
||||||
@@ -495,6 +654,6 @@
|
|||||||
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<IncludePath>C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Game;C:\Users\Bram\Desktop\Programming 2\Exam\dae16-VerhulstBram\Engine\imgui;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
<IncludePath>$(SolutionDir)Game;$(SolutionDir)Engine\imgui;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -69,6 +69,9 @@
|
|||||||
<ClCompile Include="Levels\World\WorldLevel.cpp">
|
<ClCompile Include="Levels\World\WorldLevel.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="GroundTileTypeManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Game.h">
|
<ClInclude Include="Game.h">
|
||||||
@@ -122,5 +125,8 @@
|
|||||||
<ClInclude Include="Levels\World\WorldLevel.h">
|
<ClInclude Include="Levels\World\WorldLevel.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="GroundTileTypeManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,2 +1,50 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "GameManager.h"
|
#include "GameManager.h"
|
||||||
|
|
||||||
|
GameManager* GameManager::m_pInstance = nullptr;
|
||||||
|
|
||||||
|
GameManager& GameManager::GetInstance() {
|
||||||
|
if (m_pInstance == nullptr) {
|
||||||
|
m_pInstance = new GameManager();
|
||||||
|
}
|
||||||
|
return *m_pInstance;
|
||||||
|
}
|
||||||
|
void GameManager::SetMainScreen(MainScreen* pMainScreen) {
|
||||||
|
m_pMainScreen = pMainScreen;
|
||||||
|
//TODO: not the best but ¯\_(ツ)_/¯
|
||||||
|
}
|
||||||
|
void GameManager::SetFuel(int fuel) {
|
||||||
|
m_Fuel = fuel;
|
||||||
|
}
|
||||||
|
int GameManager::GetFuel() const {
|
||||||
|
return m_Fuel;
|
||||||
|
}
|
||||||
|
void GameManager::DecreaseFuel(int fuel) {
|
||||||
|
m_Fuel -= fuel;
|
||||||
|
}
|
||||||
|
void GameManager::AddFuel(int fuel) {
|
||||||
|
m_Fuel += fuel;
|
||||||
|
}
|
||||||
|
void GameManager::SetHullIntegrity(int hullIntegrity) {
|
||||||
|
m_HullIntegrity = hullIntegrity;
|
||||||
|
}
|
||||||
|
int GameManager::GetHullIntegrity() const {
|
||||||
|
return m_HullIntegrity;
|
||||||
|
}
|
||||||
|
void GameManager::DamageHull(int damage) {
|
||||||
|
m_HullIntegrity -= damage;
|
||||||
|
}
|
||||||
|
void GameManager::SetScore(int score) {
|
||||||
|
m_Score = score;
|
||||||
|
}
|
||||||
|
int GameManager::GetScore() const {
|
||||||
|
return m_Score;
|
||||||
|
}
|
||||||
|
void GameManager::IncreaseScore(int score) {
|
||||||
|
m_Score += score;
|
||||||
|
}
|
||||||
|
void GameManager::Update(float elapsedSecs) {
|
||||||
|
m_pMainScreen->SetFuelMeterValue(m_Fuel);
|
||||||
|
m_pMainScreen->SetHullMeterValue(m_HullIntegrity);
|
||||||
|
m_pMainScreen->SetScore(std::to_string(m_Score));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,12 +1,38 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "Gui/Screens/MainScreen.h"
|
||||||
|
|
||||||
class GameManager
|
class GameManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
float balance{ 0.0f };
|
static GameManager& GetInstance();
|
||||||
float fuel{ 0.0f };
|
static GameManager* m_pInstance;
|
||||||
|
|
||||||
|
|
||||||
|
void SetMainScreen(MainScreen* pMainScreen);
|
||||||
|
|
||||||
|
void SetFuel(int fuel);
|
||||||
|
int GetFuel() const;
|
||||||
|
void DecreaseFuel(int fuel);
|
||||||
|
void AddFuel(int fuel);
|
||||||
|
|
||||||
|
void SetHullIntegrity(int hullIntegrity);
|
||||||
|
int GetHullIntegrity() const;
|
||||||
|
void DamageHull(int damage);
|
||||||
|
|
||||||
|
void SetScore(int score);
|
||||||
|
int GetScore() const;
|
||||||
|
void IncreaseScore(int score);
|
||||||
|
|
||||||
|
void Update(float elapsedSecs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameManager() = default;
|
GameManager() = default;
|
||||||
|
|
||||||
|
|
||||||
|
float m_Balance{ 0.0f };
|
||||||
|
int m_HullIntegrity{ 100 };
|
||||||
|
int m_Fuel{ 100 };
|
||||||
|
int m_Score{ 0 };
|
||||||
|
MainScreen* m_pMainScreen{ nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
31
Game/GridSystem/GroundTileTypeManager.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "GroundTileTypeManager.h"
|
||||||
|
|
||||||
|
#include "GridSystem/WorldTile.h"
|
||||||
|
|
||||||
|
GroundTileTypeManager* GroundTileTypeManager::m_pInstance = nullptr;
|
||||||
|
|
||||||
|
GroundTileTypeManager* GroundTileTypeManager::GetInstance() {
|
||||||
|
if (m_pInstance == nullptr) {
|
||||||
|
m_pInstance = new GroundTileTypeManager();
|
||||||
|
}
|
||||||
|
return m_pInstance;
|
||||||
|
}
|
||||||
|
void GroundTileTypeManager::DestroyInstance() {
|
||||||
|
delete m_pInstance->AIR;
|
||||||
|
delete m_pInstance->DIRT;
|
||||||
|
delete m_pInstance->STONE;
|
||||||
|
delete m_pInstance->LAVA;
|
||||||
|
delete m_pInstance->IRON;
|
||||||
|
delete m_pInstance->BRONZE;
|
||||||
|
delete m_pInstance->GOLD;
|
||||||
|
delete m_pInstance->HARD_LEFT;
|
||||||
|
delete m_pInstance->HARD_RIGHT;
|
||||||
|
delete m_pInstance->HARD_MIDDLE;
|
||||||
|
delete m_pInstance->GRASS;
|
||||||
|
|
||||||
|
delete m_pInstance;
|
||||||
|
}
|
||||||
|
GroundTileTypeManager::GroundTileTypeManager() = default;
|
||||||
|
|
||||||
|
GroundTileTypeManager::~GroundTileTypeManager() = default;
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include "GridSystem/WorldTile.h"
|
||||||
|
|
||||||
|
|
||||||
class GroundTileType;
|
class GroundTileType;
|
||||||
|
|
||||||
@@ -10,6 +12,23 @@ public:
|
|||||||
static GroundTileTypeManager* GetInstance();
|
static GroundTileTypeManager* GetInstance();
|
||||||
static void DestroyInstance();
|
static void DestroyInstance();
|
||||||
|
|
||||||
|
GroundTileType* AIR;
|
||||||
|
GroundTileType* DIRT;
|
||||||
|
|
||||||
|
GroundTileType* STONE;
|
||||||
|
GroundTileType* LAVA;
|
||||||
|
|
||||||
|
GroundTileType* IRON;
|
||||||
|
GroundTileType* BRONZE;
|
||||||
|
GroundTileType* GOLD;
|
||||||
|
|
||||||
|
GroundTileType* HARD_LEFT;
|
||||||
|
GroundTileType* HARD_RIGHT;
|
||||||
|
GroundTileType* HARD_MIDDLE;
|
||||||
|
|
||||||
|
GroundTileType* GRASS;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// static GroundTileType* AIR{ nullptr };
|
// static GroundTileType* AIR{ nullptr };
|
||||||
//
|
//
|
||||||
@@ -35,4 +54,3 @@ private:
|
|||||||
static GroundTileTypeManager* m_pInstance;
|
static GroundTileTypeManager* m_pInstance;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,31 +20,15 @@ WorldGridManager::~WorldGridManager() {
|
|||||||
delete m_worldTiles[x][y];
|
delete m_worldTiles[x][y];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Deleting static" << std::endl;
|
|
||||||
delete Tiles::AIR;
|
|
||||||
delete Tiles::DIRT;
|
|
||||||
|
|
||||||
delete Tiles::Hazards::LAVA;
|
|
||||||
delete Tiles::Hazards::STONE;
|
|
||||||
|
|
||||||
delete Tiles::Ores::BRONZE;
|
|
||||||
delete Tiles::Ores::GOLD;
|
|
||||||
delete Tiles::Ores::IRON;
|
|
||||||
|
|
||||||
delete Tiles::Special::GRASS;
|
|
||||||
delete Tiles::Special::HARD_LEFT;
|
|
||||||
delete Tiles::Special::HARD_MIDDLE;
|
|
||||||
delete Tiles::Special::HARD_RIGHT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_tile) {
|
surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_tile) {
|
||||||
surroundingTiles tiles;
|
surroundingTiles tiles;
|
||||||
Vector2f pos = world_tile->GetPosition();
|
Vector2f pos = world_tile->GetPosition();
|
||||||
Vector2f gridCoords = this->GetIndexFromPosition(pos);
|
Vector2f gridCoords = this->GetIndexFromPosition(pos);
|
||||||
int x = gridCoords.x;
|
const int x = (int)gridCoords.x;
|
||||||
//TODO: Stupid fix, fix this
|
//TODO: Stupid fix, fix this
|
||||||
int y = gridCoords.y - 1;
|
const int y = (int)gridCoords.y - 1;
|
||||||
|
|
||||||
tiles.SetTile(TileDirection::TopLeft, this->GetTileAtIndex(x - 1, y - 1));
|
tiles.SetTile(TileDirection::TopLeft, this->GetTileAtIndex(x - 1, y - 1));
|
||||||
tiles.SetTile(TileDirection::TopMiddle, this->GetTileAtIndex(x, y - 1));
|
tiles.SetTile(TileDirection::TopMiddle, this->GetTileAtIndex(x, y - 1));
|
||||||
@@ -63,7 +47,7 @@ surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_ti
|
|||||||
Vector2f WorldGridManager::GetIndexFromPosition(Vector2f position) {
|
Vector2f WorldGridManager::GetIndexFromPosition(Vector2f position) {
|
||||||
int x = int(position.x / TILE_WIDTH + WORLD_WIDTH / 2);
|
int x = int(position.x / TILE_WIDTH + WORLD_WIDTH / 2);
|
||||||
int y = int(-position.y / TILE_HEIGHT);
|
int y = int(-position.y / TILE_HEIGHT);
|
||||||
return Vector2f{ float(x), float(y) };
|
return Vector2f { float(x), float(y) };
|
||||||
}
|
}
|
||||||
WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
|
WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
|
||||||
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
|
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ static const int TILE_HEIGHT = 50;
|
|||||||
|
|
||||||
class WorldTile;
|
class WorldTile;
|
||||||
|
|
||||||
enum TileDirection
|
enum TileDirection {
|
||||||
{
|
|
||||||
TopLeft,
|
TopLeft,
|
||||||
TopMiddle,
|
TopMiddle,
|
||||||
TopRight,
|
TopRight,
|
||||||
@@ -29,41 +28,31 @@ enum TileDirection
|
|||||||
BottomRight
|
BottomRight
|
||||||
};
|
};
|
||||||
|
|
||||||
struct surroundingTiles
|
struct surroundingTiles {
|
||||||
{
|
|
||||||
|
|
||||||
std::map<TileDirection, WorldTile *> m_tiles;
|
std::vector<WorldTile *> m_tiles { 8, nullptr };
|
||||||
|
|
||||||
void SetTile(TileDirection direction, WorldTile* tile) {
|
void SetTile(TileDirection direction, WorldTile* tile) {
|
||||||
m_tiles[direction] = tile;
|
m_tiles[static_cast<int>(direction)] = tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldTile* GetTile(TileDirection direction) {
|
WorldTile * GetTile(TileDirection direction) {
|
||||||
return m_tiles[direction];
|
return m_tiles[static_cast<int>(direction)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool IsAllType(const GroundTileType& type) {
|
|
||||||
// for (const auto& tile : m_tiles) {
|
|
||||||
// if (tile.second == nullptr) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// if (tile.second->GetTileType() != &type) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorldGridManager
|
class WorldGridManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
WorldGridManager();
|
WorldGridManager();
|
||||||
~WorldGridManager();
|
~WorldGridManager();
|
||||||
surroundingTiles GetSurroundingTiles(const WorldTile* world_tile);
|
surroundingTiles GetSurroundingTiles(const WorldTile* world_tile);
|
||||||
Vector2f GetIndexFromPosition(Vector2f position);
|
static Vector2f GetIndexFromPosition(Vector2f position);
|
||||||
|
|
||||||
|
WorldGridManager(const WorldGridManager& other) = delete;
|
||||||
|
WorldGridManager(WorldGridManager&& other) = default;
|
||||||
|
WorldGridManager& operator=(const WorldGridManager& other) = delete;
|
||||||
|
WorldGridManager& operator=(WorldGridManager&& other) = delete;
|
||||||
|
|
||||||
WorldGridManager(const WorldGridManager& other) = default;
|
|
||||||
|
|
||||||
WorldTile * GetTileAtIndex(const int x, const int y) const;
|
WorldTile * GetTileAtIndex(const int x, const int y) const;
|
||||||
WorldTile * GetTileAtWorldPos(const Vector2f& pos) const;
|
WorldTile * GetTileAtWorldPos(const Vector2f& pos) const;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
#include "GroundTileTypeManager.h"
|
||||||
#include "../TextureManager.h"
|
#include "../TextureManager.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "WorldGridManager.h"
|
#include "WorldGridManager.h"
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
GroundTileType* getRandomGroundTile() {
|
GroundTileType * getRandomGroundTile() {
|
||||||
// Generate a random weight between 0 and the sum of weights
|
// Generate a random weight between 0 and the sum of weights
|
||||||
float sumWeights = 0.0f;
|
float sumWeights = 0.0f;
|
||||||
for (const auto& pair : GroundTileWeights) {
|
for (const auto& pair : GroundTileWeights) {
|
||||||
@@ -31,13 +32,42 @@ GroundTileType* getRandomGroundTile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This should never be reached if weights sum to 1.0
|
// This should never be reached if weights sum to 1.0
|
||||||
return Tiles::AIR; // Default value
|
return GroundTileTypeManager::GetInstance()->AIR; // Default value
|
||||||
}
|
}
|
||||||
// void InitializeGroundTiles() {
|
void InitializeGroundTiles() {
|
||||||
//
|
Tiles tiles {};
|
||||||
// Tiles::AIR = new GroundTileType("", GroundTileTypes::Air);
|
GroundTileTypeManager::GetInstance()->AIR = new GroundTileType("", GroundTileTypes::Air);
|
||||||
// }
|
GroundTileTypeManager::GetInstance()->DIRT = new RandomGroundTile("tiles/dirt/dirt[0].png", GroundTileTypes::Dirt, 5);
|
||||||
WorldTile::WorldTile(const Vector2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager) : m_Position { position }, m_GroundTileType { groundTileType }, m_pGridManager { pGridManager } {
|
|
||||||
|
GroundTileTypeManager::GetInstance()->STONE = new RandomGroundTile("tiles/ores/Ore_Stone_[0].png", GroundTileTypes::Stone, 3);
|
||||||
|
GroundTileTypeManager::GetInstance()->LAVA = new RandomGroundTile("tiles/ores/Ore_Lava_[0].png", GroundTileTypes::Lava, 3);
|
||||||
|
|
||||||
|
GroundTileTypeManager::GetInstance()->IRON = new GroundTileType("tiles/ores/Ore_Ironium.png", GroundTileTypes::Iron);
|
||||||
|
GroundTileTypeManager::GetInstance()->BRONZE = new GroundTileType("tiles/ores/Ore_Bronzium.png", GroundTileTypes::Bronze);
|
||||||
|
GroundTileTypeManager::GetInstance()->GOLD = new GroundTileType("tiles/ores/Ore_Goldium.png", GroundTileTypes::Gold);
|
||||||
|
|
||||||
|
GroundTileTypeManager::GetInstance()->GRASS = new RandomGroundTile("tiles/dirt/special/grass[0].png", GroundTileTypes::Grass, 2);
|
||||||
|
GroundTileTypeManager::GetInstance()->HARD_LEFT = new GroundTileType("tiles/dirt/special/hardLeft.png", GroundTileTypes::Hard);
|
||||||
|
GroundTileTypeManager::GetInstance()->HARD_RIGHT = new GroundTileType("tiles/dirt/special/hardRight.png", GroundTileTypes::Hard);
|
||||||
|
GroundTileTypeManager::GetInstance()->HARD_MIDDLE = new GroundTileType("tiles/dirt/special/hardMiddle.png", GroundTileTypes::Hard);
|
||||||
|
|
||||||
|
GroundTileWeights = {
|
||||||
|
{ GroundTileTypeManager::GetInstance()->AIR, 0.2f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->DIRT, 0.5f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->GRASS, 0.0f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->STONE, 0.025f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->LAVA, 0.01f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->HARD_LEFT, 0.0f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->HARD_MIDDLE, 0.0f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->HARD_RIGHT, 0.0f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->BRONZE, 0.05f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->GOLD, 0.02f },
|
||||||
|
{ GroundTileTypeManager::GetInstance()->IRON, 0.1f },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldTile::WorldTile(const Vector2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager) : m_Position { position },
|
||||||
|
m_GroundTileType { groundTileType }, m_pGridManager { pGridManager } {
|
||||||
// const std::string dirtPath = + "tiles/dirt/dirt" + std::to_string(utils::randRange(1, 5)) + ".png";
|
// const std::string dirtPath = + "tiles/dirt/dirt" + std::to_string(utils::randRange(1, 5)) + ".png";
|
||||||
// m_pTexture = new Texture(dirtPath);
|
// m_pTexture = new Texture(dirtPath);
|
||||||
m_pTexture = pTextureManager->GetTexture(groundTileType->getPath());
|
m_pTexture = pTextureManager->GetTexture(groundTileType->getPath());
|
||||||
@@ -63,22 +93,23 @@ void WorldTile::Draw() {
|
|||||||
switch (m_GroundTileType->getType()) {
|
switch (m_GroundTileType->getType()) {
|
||||||
case GroundTileTypes::Air: {
|
case GroundTileTypes::Air: {
|
||||||
//check if it's all around dirt
|
//check if it's all around dirt
|
||||||
bool allDirt = true;
|
// bool allDirt = true;
|
||||||
for (int i = 0; i < 8; i++) {
|
// TileDirection allDirtDirections[] { TileDirection::BottomMiddle, TileDirection::MiddleLeft, TileDirection::MiddleRight, TileDirection::TopMiddle };
|
||||||
const WorldTile* tile = m_SurroundingTiles.GetTile(static_cast<TileDirection>(i));
|
// for (int i = 0; i < 3; i++) {
|
||||||
if(tile != nullptr) { //Tile exists
|
// const WorldTile* tile = m_SurroundingTiles.GetTile(allDirtDirections[i]);
|
||||||
const GroundTileTypes type = tile->GetTileType()->getType();
|
// if (tile != nullptr) { //Tile exists
|
||||||
if(type != Tiles::DIRT->getType()) {
|
// const GroundTileTypes type = tile->GetTileType()->getType();
|
||||||
allDirt = false;
|
// if (type != GroundTileTypeManager::GetInstance()->DIRT->getType()) {
|
||||||
break;
|
// allDirt = false;
|
||||||
}
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if(allDirt) {
|
// }
|
||||||
m_pAllTexture->Draw(m_Position);
|
// if (allDirt) {
|
||||||
return;
|
// m_pAllTexture->Draw(m_Position);
|
||||||
}
|
// return;
|
||||||
if(*m_GroundTileType == Tiles::AIR) {
|
// }
|
||||||
|
// else {
|
||||||
this->DrawSide(TileDirection::TopLeft);
|
this->DrawSide(TileDirection::TopLeft);
|
||||||
this->DrawSide(TileDirection::TopRight);
|
this->DrawSide(TileDirection::TopRight);
|
||||||
this->DrawSide(TileDirection::BottomLeft);
|
this->DrawSide(TileDirection::BottomLeft);
|
||||||
@@ -88,10 +119,9 @@ void WorldTile::Draw() {
|
|||||||
this->DrawSide(TileDirection::BottomMiddle);
|
this->DrawSide(TileDirection::BottomMiddle);
|
||||||
this->DrawSide(TileDirection::MiddleLeft);
|
this->DrawSide(TileDirection::MiddleLeft);
|
||||||
this->DrawSide(TileDirection::MiddleRight);
|
this->DrawSide(TileDirection::MiddleRight);
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
case GroundTileTypes::Dirt:
|
case GroundTileTypes::Dirt:
|
||||||
case GroundTileTypes::Hard:
|
case GroundTileTypes::Hard:
|
||||||
case GroundTileTypes::Stone:
|
case GroundTileTypes::Stone:
|
||||||
@@ -103,7 +133,7 @@ void WorldTile::Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (*m_GroundTileType != Tiles::AIR) {
|
if (*m_GroundTileType != GroundTileTypeManager::GetInstance()->AIR) {
|
||||||
m_pTexture->Draw(m_Position);
|
m_pTexture->Draw(m_Position);
|
||||||
if (m_Hightlight) {
|
if (m_Hightlight) {
|
||||||
utils::SetColor(Colors::GREEN);
|
utils::SetColor(Colors::GREEN);
|
||||||
@@ -112,15 +142,13 @@ void WorldTile::Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldTile::Update(const Camera* camera) {
|
void WorldTile::Update(const Camera* camera) {
|
||||||
m_pGridManager->GetIndexFromPosition(m_Position);
|
m_pGridManager->GetIndexFromPosition(m_Position);
|
||||||
m_SurroundingTiles = m_pGridManager->GetSurroundingTiles(this);
|
m_SurroundingTiles = m_pGridManager->GetSurroundingTiles(this);
|
||||||
const Vector2f mouse_pos = camera->TransformMouse(Vector2f{utils::GetMousePos().x, 500 - utils::GetMousePos().y});
|
const Vector2f mouse_pos = camera->TransformMouse(Vector2f { utils::GetMousePos().x, 500 - utils::GetMousePos().y });
|
||||||
m_Hightlight = utils::IsPointInRect(mouse_pos, Rectf{GetCollisionRect().pos, GetCollisionRect().size});
|
m_Hightlight = utils::IsPointInRect(mouse_pos, Rectf { GetCollisionRect().pos, GetCollisionRect().size });
|
||||||
}
|
}
|
||||||
Collision::TileCollisionRect WorldTile::GetCollisionRect() {
|
Collision::TileCollisionRect WorldTile::GetCollisionRect() {
|
||||||
return Collision::TileCollisionRect { m_Position, GetSize(), ( this ) };
|
return Collision::TileCollisionRect { m_Position, GetSize(), ( this ) };
|
||||||
@@ -128,17 +156,18 @@ Collision::TileCollisionRect WorldTile::GetCollisionRect() {
|
|||||||
|
|
||||||
void WorldTile::DrawSide(const TileDirection& direction) {
|
void WorldTile::DrawSide(const TileDirection& direction) {
|
||||||
const WorldTile* tile = m_SurroundingTiles.GetTile(direction);
|
const WorldTile* tile = m_SurroundingTiles.GetTile(direction);
|
||||||
if(tile != nullptr) {
|
if (tile != nullptr) {
|
||||||
const GroundTileTypes type = tile->GetTileType()->getType();
|
const GroundTileTypes type = tile->GetTileType()->getType();
|
||||||
if(direction == TileDirection::BottomMiddle || direction == TileDirection::BottomLeft || direction == TileDirection::BottomRight) {
|
if (direction == TileDirection::BottomMiddle || direction == TileDirection::BottomLeft || direction == TileDirection::BottomRight) {
|
||||||
if(type == Tiles::Special::GRASS->getType() || type == Tiles::Special::HARD_LEFT->getType() || type == Tiles::Special::HARD_MIDDLE->getType() || type == Tiles::Special::HARD_RIGHT->getType()) {
|
if (type == GroundTileTypeManager::GetInstance()->GRASS->getType() || type == GroundTileTypeManager::GetInstance()->HARD_LEFT->getType() || type ==
|
||||||
|
GroundTileTypeManager::GetInstance()->HARD_MIDDLE->getType() || type == GroundTileTypeManager::GetInstance()->HARD_RIGHT->getType()) {
|
||||||
//Fix for edges being renderd on grass / hard tiles
|
//Fix for edges being renderd on grass / hard tiles
|
||||||
//TODO: Possible fix if i have time
|
//TODO: Possible fix if i have time
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type != Tiles::AIR->getType()) {
|
if (type != GroundTileTypeManager::GetInstance()->AIR->getType()) {
|
||||||
m_SideTextures[direction]->Draw(m_Position);
|
m_SideTextures[direction]->Draw(m_Position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,48 +108,28 @@ private:
|
|||||||
int m_maxRandom;
|
int m_maxRandom;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Tiles
|
class Tiles
|
||||||
{
|
{
|
||||||
static GroundTileType* AIR = new GroundTileType("", GroundTileTypes::Air);
|
public:
|
||||||
static GroundTileType* DIRT = new RandomGroundTile("tiles/dirt/dirt[0].png", GroundTileTypes::Dirt, 5);
|
|
||||||
|
|
||||||
namespace Hazards
|
|
||||||
{
|
|
||||||
static GroundTileType* STONE = new RandomGroundTile("tiles/ores/Ore_Stone_[0].png", GroundTileTypes::Stone, 3);
|
|
||||||
static GroundTileType* LAVA = new RandomGroundTile("tiles/ores/Ore_Lava_[0].png", GroundTileTypes::Lava, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Ores
|
|
||||||
{
|
|
||||||
static GroundTileType* IRON = new GroundTileType("tiles/ores/Ore_Ironium.png", GroundTileTypes::Iron);
|
|
||||||
static GroundTileType* BRONZE = new GroundTileType("tiles/ores/Ore_Bronzium.png", GroundTileTypes::Bronze);
|
|
||||||
static GroundTileType* GOLD = new GroundTileType("tiles/ores/Ore_Goldium.png", GroundTileTypes::Gold);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Special
|
|
||||||
{
|
|
||||||
static GroundTileType* HARD_LEFT = new GroundTileType("tiles/dirt/special/hardLeft.png", GroundTileTypes::Hard);
|
|
||||||
static GroundTileType* HARD_RIGHT = new GroundTileType("tiles/dirt/special/hardRight.png", GroundTileTypes::Hard);
|
|
||||||
static GroundTileType* HARD_MIDDLE = new GroundTileType("tiles/dirt/special/hardMiddle.png", GroundTileTypes::Hard);
|
|
||||||
|
|
||||||
static GroundTileType* GRASS = new RandomGroundTile("tiles/dirt/special/grass[0].png", GroundTileTypes::Grass, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::map<GroundTileType *, float> GroundTileWeights {
|
|
||||||
{ Tiles::AIR, 0.2f },
|
|
||||||
{ Tiles::DIRT, 0.5f },
|
|
||||||
{ Tiles::Special::GRASS, 0.0f },
|
|
||||||
{ Tiles::Hazards::STONE, 0.025f },
|
|
||||||
{ Tiles::Hazards::LAVA, 0.01f },
|
|
||||||
{ Tiles::Special::HARD_LEFT, 0.0f },
|
|
||||||
{ Tiles::Special::HARD_MIDDLE, 0.0f },
|
|
||||||
{ Tiles::Special::HARD_RIGHT, 0.0f },
|
|
||||||
{ Tiles::Ores::BRONZE, 0.05f },
|
|
||||||
{ Tiles::Ores::GOLD, 0.02f },
|
|
||||||
{ Tiles::Ores::IRON, 0.1f },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// static std::map<GroundTileType *, float> GroundTileWeights {
|
||||||
|
// { Tiles::AIR, 0.2f },
|
||||||
|
// { Tiles::DIRT, 0.5f },
|
||||||
|
// { Tiles::Special::GRASS, 0.0f },
|
||||||
|
// { Tiles::Hazards::STONE, 0.025f },
|
||||||
|
// { Tiles::Hazards::LAVA, 0.01f },
|
||||||
|
// { Tiles::Special::HARD_LEFT, 0.0f },
|
||||||
|
// { Tiles::Special::HARD_MIDDLE, 0.0f },
|
||||||
|
// { Tiles::Special::HARD_RIGHT, 0.0f },
|
||||||
|
// { Tiles::Ores::BRONZE, 0.05f },
|
||||||
|
// { Tiles::Ores::GOLD, 0.02f },
|
||||||
|
// { Tiles::Ores::IRON, 0.1f },
|
||||||
|
// };
|
||||||
|
|
||||||
|
static std::map<GroundTileType*, float> GroundTileWeights;
|
||||||
|
|
||||||
void InitializeGroundTiles();
|
void InitializeGroundTiles();
|
||||||
|
|
||||||
class WorldTile
|
class WorldTile
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#include "pch.h"
|
|
||||||
#include "GroundTileTypeManager.h"
|
|
||||||
|
|
||||||
#include "GridSystem/WorldTile.h"
|
|
||||||
|
|
||||||
GroundTileTypeManager* GroundTileTypeManager::m_pInstance = nullptr;
|
|
||||||
|
|
||||||
GroundTileTypeManager* GroundTileTypeManager::GetInstance() {
|
|
||||||
if (m_pInstance == nullptr) {
|
|
||||||
m_pInstance = new GroundTileTypeManager();
|
|
||||||
}
|
|
||||||
return m_pInstance;
|
|
||||||
}
|
|
||||||
void GroundTileTypeManager::DestroyInstance() {
|
|
||||||
}
|
|
||||||
// void GroundTileTypeManager::Initialize() {
|
|
||||||
// AIR = new GroundTileType("", GroundTileTypes::Air);
|
|
||||||
// }
|
|
||||||
GroundTileTypeManager::GroundTileTypeManager() {
|
|
||||||
}
|
|
||||||
GroundTileTypeManager::~GroundTileTypeManager() {
|
|
||||||
}
|
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "Button.h"
|
#include "GuiButton.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
Button::Button(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
|
GuiButton::GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
|
||||||
m_Texture = manager->GetTexture(filePath);
|
m_Texture = manager->GetTexture(filePath);
|
||||||
if(size.x == 0 && size.y == 0) {
|
if(size.x == 0 && size.y == 0) {
|
||||||
m_Size = Vector2f{float(m_Texture->GetWidth()), float(m_Texture->GetHeight())};
|
m_Size = Vector2f{float(m_Texture->GetWidth()), float(m_Texture->GetHeight())};
|
||||||
}
|
}
|
||||||
std::cout << "Button created" << '\n';
|
std::cout << "Button created" << '\n';
|
||||||
}
|
}
|
||||||
Button::~Button() {
|
GuiButton::~GuiButton() {
|
||||||
std::cout << "Button destroyed" << '\n';
|
std::cout << "Button destroyed" << '\n';
|
||||||
}
|
}
|
||||||
void Button::Draw() const {
|
void GuiButton::Draw() const {
|
||||||
Rectf dest = Rectf(m_Position, m_Size);
|
Rectf dest = Rectf(m_Position, m_Size);
|
||||||
Rectf src = Rectf(0, 0, m_Texture->GetWidth(), m_Texture->GetHeight());
|
Rectf src = Rectf(0, 0, m_Texture->GetWidth(), m_Texture->GetHeight());
|
||||||
if(m_IsHovered) {
|
if(m_IsHovered) {
|
||||||
m_Texture->Draw(dest, src, false);
|
m_Texture->Draw(dest, src, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Button::Update(float elapsedSec) {
|
void GuiButton::Update(float elapsedSec) {
|
||||||
Vector2f mousePos = utils::GetMousePos();
|
Vector2f mousePos = utils::GetMousePos();
|
||||||
Rectf buttonRect = Rectf(m_Position, m_Size);
|
Rectf buttonRect = Rectf(m_Position, m_Size);
|
||||||
|
|
||||||
@@ -2,17 +2,18 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "GuiElement.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "../TextureManager.h"
|
#include "../TextureManager.h"
|
||||||
|
|
||||||
class Button
|
class GuiButton : public GuiElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button() = default;
|
GuiButton() = default;
|
||||||
Button(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
|
GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
|
||||||
~Button();
|
~GuiButton() override;
|
||||||
void Draw() const;
|
virtual void Draw() const override;
|
||||||
void Update(float elapsedSec);
|
virtual void Update(float elapsedSec) override;
|
||||||
|
|
||||||
void SetOnClick(std::function<void(void)> onClick) {
|
void SetOnClick(std::function<void(void)> onClick) {
|
||||||
m_OnClick = onClick;
|
m_OnClick = onClick;
|
||||||
2
Game/Gui/GuiElement.cpp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "GuiElement.h"
|
||||||
14
Game/Gui/GuiElement.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class GuiElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiElement() = default;
|
||||||
|
virtual ~GuiElement() = default;
|
||||||
|
|
||||||
|
virtual void Draw() const = 0;
|
||||||
|
virtual void Update(float elapsedSec) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
27
Game/Gui/GuiMeter.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "GuiMeter.h"
|
||||||
|
|
||||||
|
#include "TextureManager.h"
|
||||||
|
#include "utils.h"
|
||||||
|
GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager): GuiMeter(
|
||||||
|
filePath, pos, frameSize, frameSize, frameCount, manager) {
|
||||||
|
}
|
||||||
|
GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, Vector2f drawSize, int frameCount, TextureManager* manager): m_Position(pos),
|
||||||
|
m_DrawSize(drawSize), m_FrameCount(frameCount) {
|
||||||
|
m_Animation = new Animation(manager->GetTexture(filePath), frameCount, 0.0f, Rectf { 0, 0, frameSize.x, frameSize.y }, false);
|
||||||
|
}
|
||||||
|
GuiMeter::~GuiMeter() {
|
||||||
|
delete m_Animation;
|
||||||
|
}
|
||||||
|
void GuiMeter::Draw() const {
|
||||||
|
m_Animation->Draw(m_Position, Rectf{m_Position, m_DrawSize});
|
||||||
|
utils::DrawRect(Rectf { m_Position, m_DrawSize});
|
||||||
|
}
|
||||||
|
void GuiMeter::Update(float elapsedSec) {
|
||||||
|
m_Value += 1;
|
||||||
|
const int frame = static_cast<int>(utils::map(m_Value, 0.0f, m_MaxValue, 0, (float)m_Animation->GetFrameCount()));
|
||||||
|
m_Animation->SetFrame(frame);
|
||||||
|
}
|
||||||
|
void GuiMeter::SetValue(float value) {
|
||||||
|
m_Value = value;
|
||||||
|
}
|
||||||
34
Game/Gui/GuiMeter.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "GuiElement.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
#include "Animations/Animation.h"
|
||||||
|
|
||||||
|
class TextureManager;
|
||||||
|
|
||||||
|
class GuiMeter final : public GuiElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager);
|
||||||
|
GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, Vector2f drawSize, int frameCount, TextureManager* manager);
|
||||||
|
GuiMeter(GuiMeter& other) = delete;
|
||||||
|
GuiMeter& operator=(const GuiMeter& other) = delete;
|
||||||
|
GuiMeter(GuiMeter&& other) = delete;
|
||||||
|
GuiMeter& operator=(GuiMeter&& other) = delete;
|
||||||
|
virtual ~GuiMeter() override;
|
||||||
|
|
||||||
|
virtual void Draw() const override;
|
||||||
|
virtual void Update(float elapsedSec) override;
|
||||||
|
|
||||||
|
void SetValue(float value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Animation* m_Animation{ nullptr };
|
||||||
|
Vector2f m_Position;
|
||||||
|
Vector2f m_DrawSize;
|
||||||
|
|
||||||
|
float m_Value{ 0.0f };
|
||||||
|
const float m_MaxValue{ 100.0f };
|
||||||
|
|
||||||
|
int m_FrameCount;
|
||||||
|
|
||||||
|
};
|
||||||
26
Game/Gui/GuiText.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "GuiText.h"
|
||||||
|
|
||||||
|
#include "colors.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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiText::GuiText(): m_Position(100,100), m_Text(new Text("Undefined", "fonts/verdana.ttf", 10, Colors::WHITE)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiText::Draw() const {
|
||||||
|
m_Text->Draw(m_Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiText::Update(float elapsedSec) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiText::ChangeText(const std::string& text) const {
|
||||||
|
m_Text->ChangeText(text);
|
||||||
|
|
||||||
|
}
|
||||||
|
GuiText::~GuiText() {
|
||||||
|
delete m_Text;
|
||||||
|
}
|
||||||
20
Game/Gui/GuiText.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "GuiElement.h"
|
||||||
|
#include "Text.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class GuiText : public GuiElement {
|
||||||
|
public:
|
||||||
|
GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color);
|
||||||
|
GuiText();
|
||||||
|
|
||||||
|
void Draw() const override;
|
||||||
|
void Update(float elapsedSec) override;
|
||||||
|
|
||||||
|
void ChangeText(const std::string& text) const;
|
||||||
|
|
||||||
|
~GuiText() override;
|
||||||
|
private:
|
||||||
|
Vector2f m_Position;
|
||||||
|
Text* m_Text;
|
||||||
|
};
|
||||||
@@ -2,24 +2,30 @@
|
|||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
|
|
||||||
Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
|
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);
|
m_Background = manager->GetTexture(filePath);
|
||||||
|
} else {
|
||||||
|
m_Background = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Screen::~Screen() {
|
Screen::~Screen() {
|
||||||
for (Button* b : m_Buttons) {
|
for (GuiElement* b : m_Elements) {
|
||||||
delete b;
|
delete b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Screen::Update(float elapsedSecs) {
|
void Screen::Update(float elapsedSecs) {
|
||||||
for (Button* b : m_Buttons) {
|
for (GuiElement* b : m_Elements) {
|
||||||
b->Update(elapsedSecs);
|
b->Update(elapsedSecs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Screen::Draw() const {
|
void Screen::Draw() const {
|
||||||
|
if(m_Background != nullptr) { //Incase there is no background
|
||||||
Rectf dest = Rectf(m_Position, m_Size);
|
Rectf dest = Rectf(m_Position, m_Size);
|
||||||
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());
|
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());
|
||||||
m_Background->Draw(dest, src, false);
|
m_Background->Draw(dest, src, false);
|
||||||
|
}
|
||||||
|
|
||||||
for (Button* b : m_Buttons) {
|
for (GuiElement* GuiElement : m_Elements) {
|
||||||
b->Draw();
|
GuiElement->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Button.h"
|
#include "GuiButton.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "../TextureManager.h"
|
#include "../TextureManager.h"
|
||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
|
|
||||||
virtual ~Screen();
|
virtual ~Screen();
|
||||||
|
|
||||||
void AddButton(Button* button) { m_Buttons.push_back(button); }
|
void AddElement(GuiElement* element) { m_Elements.push_back(element); }
|
||||||
|
|
||||||
virtual void Update(float elapsedSecs);
|
virtual void Update(float elapsedSecs);
|
||||||
virtual void Draw() const;
|
virtual void Draw() const;
|
||||||
@@ -24,5 +24,5 @@ private:
|
|||||||
|
|
||||||
Texture* m_Background{ nullptr };
|
Texture* m_Background{ nullptr };
|
||||||
|
|
||||||
std::vector<Button*> m_Buttons;
|
std::vector<GuiElement*> m_Elements;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,34 +15,33 @@ FuelScreen::FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size,
|
|||||||
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
|
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
|
||||||
Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset;
|
Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset;
|
||||||
closeButtonPos.y -= 18;
|
closeButtonPos.y -= 18;
|
||||||
Button* closeFuelButton = new Button { "gui/close.png", closeButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||||
closeFuelButton->SetOnClick([this]() { ScreenManager::GetInstance()->CloseScreen(); });
|
closeFuelButton->SetOnClick([this]() { ScreenManager::GetInstance()->CloseScreen(); });
|
||||||
this->AddButton(closeFuelButton);
|
this->AddElement(closeFuelButton);
|
||||||
|
|
||||||
const Vector2f oneDollarButtonPos = Vector2f { 451, 287 };
|
const Vector2f oneDollarButtonPos = Vector2f { 451, 287 };
|
||||||
Button* fiveDollarButton = new Button { "gui/fuel/5dollars.png", oneDollarButtonPos , Vector2f{0,0}, TextureManager::GetInstance() };
|
GuiButton* fiveDollarButton = new GuiButton { "gui/fuel/5dollars.png", oneDollarButtonPos , Vector2f{0,0}, TextureManager::GetInstance() };
|
||||||
this->AddButton(fiveDollarButton);
|
this->AddElement(fiveDollarButton);
|
||||||
|
|
||||||
const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 };
|
const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 };
|
||||||
Button* tenDollarButton = new Button { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
GuiButton* tenDollarButton = new GuiButton { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||||
this->AddButton(tenDollarButton);
|
this->AddElement(tenDollarButton);
|
||||||
|
|
||||||
const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 };
|
const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 };
|
||||||
Button* twentyFiveDollarButton = new Button { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
GuiButton* twentyFiveDollarButton = new GuiButton { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||||
this->AddButton(twentyFiveDollarButton);
|
this->AddElement(twentyFiveDollarButton);
|
||||||
|
|
||||||
const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 };
|
const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 };
|
||||||
Button* fiftyDollarButton = new Button { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
GuiButton* fiftyDollarButton = new GuiButton { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||||
this->AddButton(fiftyDollarButton);
|
this->AddElement(fiftyDollarButton);
|
||||||
|
|
||||||
const Vector2f fillTankButtonPos = Vector2f { 450, 108 };
|
const Vector2f fillTankButtonPos = Vector2f { 450, 108 };
|
||||||
Button* fillTankButton = new Button { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
GuiButton* fillTankButton = new GuiButton { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||||
this->AddButton(fillTankButton);
|
this->AddElement(fillTankButton);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FuelScreen::~FuelScreen() {
|
FuelScreen::~FuelScreen() = default;
|
||||||
}
|
|
||||||
|
|
||||||
void FuelScreen::Draw() const {
|
void FuelScreen::Draw() const {
|
||||||
Screen::Draw();
|
Screen::Draw();
|
||||||
|
|||||||
45
Game/Gui/Screens/MainScreen.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "MainScreen.h"
|
||||||
|
|
||||||
|
#include "colors.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "Gui/GuiText.h"
|
||||||
|
MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vector2f{900.f, 500.f}, manager) {
|
||||||
|
Vector2f ScreenSize = utils::GetViewport();
|
||||||
|
Vector2f FuelFrameSize{ 336, 77 };
|
||||||
|
Vector2f HullFrameSize{ 61, 76 };
|
||||||
|
|
||||||
|
m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f{HullFrameSize.x + 10, ScreenSize.y - FuelFrameSize.y }, FuelFrameSize,FuelFrameSize / 1.3, 21, manager);
|
||||||
|
this->AddElement(m_FuelMeter);
|
||||||
|
|
||||||
|
m_HullMeter = new GuiMeter("gui/main/hull/hull.png", Vector2f{5, ScreenSize.y - HullFrameSize.y - 10 }, HullFrameSize, HullFrameSize, 50, manager);
|
||||||
|
this->AddElement(m_HullMeter);
|
||||||
|
|
||||||
|
Vector2f DepthMeterPosition{10, ScreenSize.y - 120};
|
||||||
|
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);
|
||||||
|
this->AddElement(m_ScoreText);
|
||||||
|
}
|
||||||
|
MainScreen::~MainScreen() = default;
|
||||||
|
void MainScreen::Draw() const {
|
||||||
|
Screen::Draw();
|
||||||
|
}
|
||||||
|
void MainScreen::Update(float elapsedSecs) {
|
||||||
|
Screen::Update(elapsedSecs);
|
||||||
|
}
|
||||||
|
void MainScreen::SetFuelMeterValue(float value) const {
|
||||||
|
m_FuelMeter->SetValue(value);
|
||||||
|
}
|
||||||
|
void MainScreen::SetHullMeterValue(float value) const {
|
||||||
|
m_HullMeter->SetValue(value);
|
||||||
|
}
|
||||||
|
void MainScreen::SetDepth(const std::string& text) const {
|
||||||
|
m_DepthText->ChangeText(text);
|
||||||
|
}
|
||||||
|
void MainScreen::SetScore(const std::string& text) const {
|
||||||
|
m_ScoreText->ChangeText(text);
|
||||||
|
}
|
||||||
|
|
||||||
27
Game/Gui/Screens/MainScreen.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Gui/GuiMeter.h"
|
||||||
|
#include "Gui/GuiText.h"
|
||||||
|
#include "Gui/Screen.h"
|
||||||
|
|
||||||
|
class MainScreen: public Screen {
|
||||||
|
public:
|
||||||
|
explicit MainScreen(TextureManager* manager);
|
||||||
|
virtual ~MainScreen() override;
|
||||||
|
|
||||||
|
virtual void Draw() const override;
|
||||||
|
virtual void Update(float elapsedSecs) override;
|
||||||
|
|
||||||
|
void SetFuelMeterValue(float value) const;
|
||||||
|
void SetHullMeterValue(float value) const;
|
||||||
|
|
||||||
|
void SetDepth(const std::string& text) const;
|
||||||
|
void SetScore(const std::string& text) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GuiMeter* m_FuelMeter;
|
||||||
|
GuiMeter* m_HullMeter;
|
||||||
|
|
||||||
|
GuiText* m_DepthText;
|
||||||
|
GuiText* m_ScoreText;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -9,5 +9,4 @@ Level::Level() : m_pCamera(nullptr) {
|
|||||||
Level::Level(Camera* camera) {
|
Level::Level(Camera* camera) {
|
||||||
m_pCamera = camera;
|
m_pCamera = camera;
|
||||||
}
|
}
|
||||||
Level::~Level() {
|
Level::~Level() = default;
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ class Level
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Level();
|
Level();
|
||||||
Level(Camera* camera);
|
explicit Level(Camera* camera);
|
||||||
virtual ~Level();
|
virtual ~Level();
|
||||||
|
|
||||||
Level(const Level& other) = default;
|
Level(const Level& other) = default;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ Building::Building(const std::string& filePath, const Vector2f& position, Textur
|
|||||||
m_Texture = pTextureManager->GetTexture(filePath);
|
m_Texture = pTextureManager->GetTexture(filePath);
|
||||||
m_Size = Vector2f(m_Texture->GetWidth(), m_Texture->GetHeight());
|
m_Size = Vector2f(m_Texture->GetWidth(), m_Texture->GetHeight());
|
||||||
}
|
}
|
||||||
Building::~Building() {
|
Building::~Building() = default;
|
||||||
}
|
|
||||||
void Building::Draw() const {
|
void Building::Draw() const {
|
||||||
m_Texture->Draw(m_Position);
|
m_Texture->Draw(m_Position);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ class Building
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Building(const std::string& filePath, const Vector2f& position, TextureManager* pTextureManager);
|
Building(const std::string& filePath, const Vector2f& position, TextureManager* pTextureManager);
|
||||||
Building(const Building& other) = delete;
|
Building(const Building& other) = default;
|
||||||
Building(Building&& other) = delete;
|
Building(Building&& other) = default;
|
||||||
|
Building& operator=(const Building& other) = default;
|
||||||
|
Building& operator=(Building&& other) = default;
|
||||||
|
|
||||||
~Building();
|
~Building();
|
||||||
|
|
||||||
|
|||||||
14
Game/Levels/World/OrbitingObject.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "OrbitingObject.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
OrbitingObject::OrbitingObject(const Vector2f& orbit, float distance, float speed, Texture* texture, float offset): m_Texture(texture), m_Orbit(orbit), m_Speed(speed), m_Distance(distance), m_currentCycle(offset) {
|
||||||
|
}
|
||||||
|
void OrbitingObject::Update(float elapsedSecs) {
|
||||||
|
m_Position = Vector2f(m_Orbit.x + cosf(m_currentCycle) * m_Distance, m_Orbit.y + sinf(m_currentCycle) * m_Distance);
|
||||||
|
m_currentCycle += m_Speed * elapsedSecs;
|
||||||
|
}
|
||||||
|
void OrbitingObject::Draw() const {
|
||||||
|
m_Texture->Draw(m_Position);
|
||||||
|
|
||||||
|
}
|
||||||
21
Game/Levels/World/OrbitingObject.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class OrbitingObject {
|
||||||
|
public:
|
||||||
|
OrbitingObject(const Vector2f& orbit, float distance, float speed, Texture* texture, float offset = 0);
|
||||||
|
|
||||||
|
void Update(float elapsedSecs);
|
||||||
|
void Draw() const;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Texture* m_Texture;
|
||||||
|
Vector2f m_Position;
|
||||||
|
Vector2f m_Orbit;
|
||||||
|
float m_Distance;
|
||||||
|
float m_Speed;
|
||||||
|
|
||||||
|
float m_currentCycle{ 0 };
|
||||||
|
|
||||||
|
};
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "Collision.h"
|
#include "Collision.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
#include "../../GridSystem/GroundTileTypeManager.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "GridSystem/WorldTile.h"
|
#include "GridSystem/WorldTile.h"
|
||||||
#include "Gui/Screens/ScreenManager.h"
|
#include "Gui/Screens/ScreenManager.h"
|
||||||
@@ -15,130 +16,132 @@
|
|||||||
|
|
||||||
class GroundTileType;
|
class GroundTileType;
|
||||||
WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||||
m_gridManager(WorldGridManager()),
|
m_GridManager(WorldGridManager()),
|
||||||
m_player(Player { Vector2f { 0, 100 }, TextureManager::GetInstance() }),
|
m_Player(Player { Vector2f { 0, 100 }, TextureManager::GetInstance() }),
|
||||||
m_mousePos { 0, 0 },
|
m_MousePos { 0, 0 },
|
||||||
m_viewport(viewport),
|
m_Viewport(viewport),
|
||||||
m_screenManager(ScreenManager::GetInstance()) {
|
m_ScreenManager(ScreenManager::GetInstance()) {
|
||||||
|
InitializeGroundTiles();
|
||||||
// The grid is 34 x 50 big, the top center is 0,0 in world coords
|
// The grid is 34 x 50 big, the top center is 0,0 in world coords
|
||||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
const int actualX = x - WORLD_WIDTH / 2;
|
const int actualX = x - WORLD_WIDTH / 2;
|
||||||
Vector2f pos = Vector2f { float(actualX * TILE_WIDTH), -float(y * TILE_HEIGHT) - TILE_HEIGHT };
|
Vector2f pos = Vector2f { float(actualX * TILE_WIDTH), -float(y * TILE_HEIGHT) - TILE_HEIGHT };
|
||||||
GroundTileType* type = getRandomGroundTile();
|
GroundTileType* type = getRandomGroundTile();
|
||||||
m_gridManager.SetTileAtIndex(x, y, new WorldTile { pos, type, TextureManager::GetInstance(), &m_gridManager });
|
m_GridManager.SetTileAtIndex(x, y, new WorldTile { pos, type, TextureManager::GetInstance(), &m_GridManager });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
m_gridManager.GetTileAtIndex(x, 0)->SetTileType(Tiles::AIR);
|
m_GridManager.GetTileAtIndex(x, 0)->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
|
||||||
m_gridManager.GetTileAtIndex(x, 1)->SetTileType(Tiles::Special::GRASS);
|
m_GridManager.GetTileAtIndex(x, 1)->SetTileType(GroundTileTypeManager::GetInstance()->GRASS);
|
||||||
}
|
}
|
||||||
m_refeulBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, TextureManager::GetInstance() };
|
m_Buildings.emplace_back(Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, TextureManager::GetInstance() });
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f { -700, -50 })->SetTileType(Tiles::Special::HARD_LEFT);
|
m_GridManager.GetTileAtWorldPos(Vector2f { -750, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f { -700, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(Tiles::Special::HARD_RIGHT);
|
m_GridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
|
m_GridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||||
|
|
||||||
m_mineralBuilding = new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, TextureManager::GetInstance() };
|
m_Buildings.emplace_back(Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, TextureManager::GetInstance() });
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(Tiles::Special::HARD_LEFT);
|
m_GridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {-250, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {-250, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {-200, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {-200, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {-150, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
|
m_GridManager.GetTileAtWorldPos(Vector2f {-150, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||||
|
|
||||||
m_junkBuilding = new Building { "buildings/junkStation.png", Vector2f { 250, -52 }, TextureManager::GetInstance() };
|
m_Buildings.emplace_back(Building { "buildings/junkStation.png", Vector2f { 250, -52 }, TextureManager::GetInstance() });
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {200, -50})->SetTileType(Tiles::Special::HARD_LEFT);
|
m_GridManager.GetTileAtWorldPos(Vector2f {200, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {250, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {250, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {300, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {300, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {350, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {350, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {400, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {400, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {450, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
|
m_GridManager.GetTileAtWorldPos(Vector2f {450, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||||
|
|
||||||
m_repairBuilding = new Building { "buildings/repairStation.png", Vector2f { 700, -52 }, TextureManager::GetInstance() };
|
m_Buildings.emplace_back(Building { "buildings/repairStation.png", Vector2f { 700, -52 }, TextureManager::GetInstance() });
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {650, -50})->SetTileType(Tiles::Special::HARD_LEFT);
|
m_GridManager.GetTileAtWorldPos(Vector2f {650, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {700, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {700, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {750, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
m_GridManager.GetTileAtWorldPos(Vector2f {750, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||||
m_gridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
|
m_GridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||||
|
// Texture* test = new Texture("gui/main/fuel_guage.png");
|
||||||
|
m_topCover = TextureManager::GetInstance()->GetTexture("topBackground.png");
|
||||||
|
|
||||||
|
m_MainScreen = new MainScreen(TextureManager::GetInstance());
|
||||||
|
|
||||||
|
m_Sun = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("sun.png"));
|
||||||
|
m_Moon = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("moon.png"), M_PI);
|
||||||
|
|
||||||
}
|
}
|
||||||
WorldLevel::~WorldLevel() {
|
WorldLevel::~WorldLevel() {
|
||||||
delete m_refeulBuilding;
|
delete m_MainScreen;
|
||||||
delete m_mineralBuilding;
|
|
||||||
delete m_junkBuilding;
|
|
||||||
delete m_repairBuilding;
|
|
||||||
//delete m_pTextTexture;
|
|
||||||
}
|
}
|
||||||
void WorldLevel::Update(float elapsedSec) {
|
void WorldLevel::Update(float elapsedSec) {
|
||||||
|
m_Fps = 1 / elapsedSec;
|
||||||
|
|
||||||
int mouseX, mouseY;
|
int mouseX, mouseY;
|
||||||
SDL_GetMouseState(&mouseX, &mouseY);
|
SDL_GetMouseState(&mouseX, &mouseY);
|
||||||
m_mousePos = Vector2f { float(mouseX), float(mouseY) };
|
m_MousePos = Vector2f { float(mouseX), float(mouseY) };
|
||||||
m_mousePos = m_pCamera->TransformMouse(m_mousePos);
|
m_MousePos = m_pCamera->TransformMouse(m_MousePos);
|
||||||
|
|
||||||
|
|
||||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
// for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
// for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
m_gridManager.GetTileAtIndex(x, y)->m_Hightlight = false;
|
// m_gridManager.GetTileAtIndex(x, y)->m_Hightlight = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
|
||||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
m_Sun->Update(elapsedSec);
|
||||||
m_gridManager.GetTileAtIndex(x, y)->Update(m_pCamera);
|
m_Moon->Update(elapsedSec);
|
||||||
if (m_gridManager.GetTileAtIndex(x, y)->GetCollisionRect().Contains(m_mousePos)) {
|
|
||||||
m_pSelectedTile = m_gridManager.GetTileAtIndex(x, y);
|
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
|
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
|
m_GridManager.GetTileAtIndex(x, y)->Update(m_pCamera);
|
||||||
|
if (m_GridManager.GetTileAtIndex(x, y)->GetCollisionRect().Contains(m_MousePos)) {
|
||||||
|
m_pSelectedTile = m_GridManager.GetTileAtIndex(x, y);
|
||||||
//selectedTile->m_Hightlight = true;
|
//selectedTile->m_Hightlight = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Building building : m_Buildings) {
|
||||||
|
building.Update(elapsedSec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_pSelectedTile != nullptr) {
|
if (m_pSelectedTile != nullptr) {
|
||||||
if (utils::isMouseDown(SDL_BUTTON_LEFT)) {
|
if (utils::isMouseDown(SDL_BUTTON_LEFT)) {
|
||||||
m_pSelectedTile->SetTileType(Tiles::AIR);
|
m_pSelectedTile->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the diogonal tiles of the selected tile
|
m_Player.Update(elapsedSec, *this);
|
||||||
if (m_pSelectedTile != nullptr) {
|
|
||||||
surroundingTiles surroundingTiles = m_gridManager.GetSurroundingTiles(m_pSelectedTile);
|
|
||||||
TileDirection direction = TileDirection::TopMiddle;
|
|
||||||
const std::array<TileDirection, 8> directions = { TileDirection::TopLeft, TileDirection::TopMiddle, TileDirection::TopRight, TileDirection::MiddleLeft,
|
|
||||||
TileDirection::MiddleRight, TileDirection::BottomLeft, TileDirection::BottomMiddle, TileDirection::BottomRight };
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
direction = directions[i];
|
|
||||||
if (surroundingTiles.GetTile(direction) != nullptr) {
|
|
||||||
if (surroundingTiles.GetTile(direction)->GetTileType() != Tiles::AIR) {
|
|
||||||
//surroundingTiles.GetTile(direction)->m_Hightlight = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_player.Update(elapsedSec, *this);
|
|
||||||
|
|
||||||
//Move the camera when the player gets to the edge
|
//Move the camera when the player gets to the edge
|
||||||
if(m_FollowPlayer) {
|
if(m_FollowPlayer) {
|
||||||
Vector2f playerPos = m_player.GetPosition();
|
Vector2f playerPos = m_Player.GetPosition();
|
||||||
Vector2f newCameraPos = m_pCamera->GetPosition();
|
Vector2f newCameraPos = m_pCamera->GetPosition();
|
||||||
if (playerPos.x < newCameraPos.x + 50) {
|
if (playerPos.x < newCameraPos.x + 50) {
|
||||||
newCameraPos.x = playerPos.x - 50;
|
newCameraPos.x = playerPos.x - 50;
|
||||||
}
|
}
|
||||||
if (playerPos.x > newCameraPos.x + m_viewport.width - 100) {
|
if (playerPos.x > newCameraPos.x + m_Viewport.width - 100) {
|
||||||
newCameraPos.x = playerPos.x - m_viewport.width + 100;
|
newCameraPos.x = playerPos.x - m_Viewport.width + 100;
|
||||||
}
|
}
|
||||||
if (playerPos.y < newCameraPos.y + 50) {
|
if (playerPos.y < newCameraPos.y + 50) {
|
||||||
newCameraPos.y = playerPos.y - 50;
|
newCameraPos.y = playerPos.y - 50;
|
||||||
}
|
}
|
||||||
if (playerPos.y > newCameraPos.y + m_viewport.height - 50) {
|
if (playerPos.y > newCameraPos.y + m_Viewport.height - 100) {
|
||||||
newCameraPos.y = playerPos.y - m_viewport.height + 50;
|
newCameraPos.y = playerPos.y - m_Viewport.height + 100;
|
||||||
}
|
}
|
||||||
m_pCamera->SetPosition(newCameraPos);
|
m_pCamera->SetPosition(newCameraPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen* screen = m_screenManager->GetCurrentScreen();
|
Screen* screen = m_ScreenManager->GetCurrentScreen();
|
||||||
if (screen != nullptr) {
|
if (screen != nullptr) {
|
||||||
screen->Update(elapsedSec);
|
screen->Update(elapsedSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_MainScreen->Update(elapsedSec);
|
||||||
|
m_MainScreen->SetDepth(std::to_string((int)-m_Player.GetPosition().y - 50) + " ft.");
|
||||||
|
|
||||||
//Vector2f playerPos = m_player.GetPosition();
|
//Vector2f playerPos = m_player.GetPosition();
|
||||||
//Vector2f newCameraPos = playerPos;
|
//Vector2f newCameraPos = playerPos;
|
||||||
//m_pCamera->SetPosition(newCameraPos);
|
//m_pCamera->SetPosition(newCameraPos);
|
||||||
@@ -147,18 +150,21 @@ void WorldLevel::Update(float elapsedSec) {
|
|||||||
//m_pCamera->SetPosition(Vector2f{playerPos.x - m_viewport.width / 2, playerPos.y - m_viewport.height / 2});
|
//m_pCamera->SetPosition(Vector2f{playerPos.x - m_viewport.width / 2, playerPos.y - m_viewport.height / 2});
|
||||||
}
|
}
|
||||||
void WorldLevel::Draw() const {
|
void WorldLevel::Draw() const {
|
||||||
|
|
||||||
m_pCamera->BeginRendering();
|
m_pCamera->BeginRendering();
|
||||||
|
// m_topCover->Draw(Vector2f{-850,-70} );
|
||||||
|
m_topCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32});
|
||||||
|
|
||||||
for (Collision::CollisionRect rect : m_Rects) {
|
for (Collision::CollisionRect rect : m_Rects) {
|
||||||
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::SetColor(Colors::WHITE);
|
utils::SetColor(Colors::WHITE);
|
||||||
utils::FillEllipse(m_mousePos, 2, 2);
|
utils::FillEllipse(m_MousePos, 2, 2);
|
||||||
|
|
||||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
m_gridManager.GetTileAtIndex(x, y)->Draw();
|
m_GridManager.GetTileAtIndex(x, y)->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,28 +175,34 @@ void WorldLevel::Draw() const {
|
|||||||
m_pSelectedTile->Draw();
|
m_pSelectedTile->Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_refeulBuilding->Draw();
|
for(Building building : m_Buildings) {
|
||||||
m_mineralBuilding->Draw();
|
building.Draw();
|
||||||
m_junkBuilding->Draw();
|
}
|
||||||
m_repairBuilding->Draw();
|
|
||||||
m_player.Draw();
|
m_Player.Draw();
|
||||||
|
|
||||||
utils::SetColor(Colors::GREEN);
|
utils::SetColor(Colors::GREEN);
|
||||||
utils::DrawArrow(Vector2f{0, 0}, m_mousePos);
|
utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
|
||||||
|
|
||||||
|
m_Sun->Draw();
|
||||||
|
m_Moon->Draw();
|
||||||
|
|
||||||
m_pCamera->EndRendering();
|
m_pCamera->EndRendering();
|
||||||
|
|
||||||
utils::FillRect(utils::GetMousePos(), 10, 10);
|
utils::FillRect(utils::GetMousePos(), 10, 10);
|
||||||
|
|
||||||
utils::DrawRect(50, 50, m_viewport.width - 100, m_viewport.height - 100);
|
utils::DrawRect(50, 50, m_Viewport.width - 100, m_Viewport.height - 100);
|
||||||
|
|
||||||
const Screen* screen = m_screenManager->GetCurrentScreen();
|
const Screen* screen = m_ScreenManager->GetCurrentScreen();
|
||||||
if (screen != nullptr) {
|
if (screen != nullptr) {
|
||||||
screen->Draw();
|
screen->Draw();
|
||||||
}
|
}
|
||||||
|
m_MainScreen->Draw();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void WorldLevel::MouseMove(const Vector2f& mousePos) {
|
void WorldLevel::MouseMove(const Vector2f& mousePos) {
|
||||||
m_mousePos = mousePos;
|
m_MousePos = mousePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldLevel::ProcessImGui() {
|
void WorldLevel::ProcessImGui() {
|
||||||
@@ -255,6 +267,10 @@ void WorldLevel::ProcessImGui() {
|
|||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu(std::to_string(m_Fps).c_str())) {
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +288,7 @@ void WorldLevel::ProcessImGui() {
|
|||||||
ImGui::Text("Camera Scale: %f", m_pCamera->GetScale());
|
ImGui::Text("Camera Scale: %f", m_pCamera->GetScale());
|
||||||
ImGui::Text("Is Right Mouse Down: %s", utils::isMouseDown(0) ? "true" : "false");
|
ImGui::Text("Is Right Mouse Down: %s", utils::isMouseDown(0) ? "true" : "false");
|
||||||
if (ImGui::Button("Reset Camera")) {
|
if (ImGui::Button("Reset Camera")) {
|
||||||
m_pCamera->SetPosition(Vector2f { -m_viewport.width / 2, -m_viewport.height / 2 });
|
m_pCamera->SetPosition(Vector2f { -m_Viewport.width / 2, -m_Viewport.height / 2 });
|
||||||
m_pCamera->SetScale(1.0f);
|
m_pCamera->SetScale(1.0f);
|
||||||
}
|
}
|
||||||
ImGui::Checkbox("Follow Player", &m_FollowPlayer);
|
ImGui::Checkbox("Follow Player", &m_FollowPlayer);
|
||||||
@@ -281,9 +297,12 @@ void WorldLevel::ProcessImGui() {
|
|||||||
|
|
||||||
if (m_ShowPlayerInfo) {
|
if (m_ShowPlayerInfo) {
|
||||||
ImGui::Begin("Player Info", &m_ShowPlayerInfo, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Player Info", &m_ShowPlayerInfo, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::Text("Player Position: (%f, %f)", m_player.GetPosition().x, m_player.GetPosition().y);
|
ImGui::Text("Player Position: (%f, %f)", m_Player.GetPosition().x, m_Player.GetPosition().y);
|
||||||
ImGui::Text("Player Velocity: (%f, %f)", m_player.GetVelocity().x, m_player.GetVelocity().y);
|
ImGui::Text("Player Velocity: (%f, %f)", m_Player.GetVelocity().x, m_Player.GetVelocity().y);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
m_player.ProcessImGui();
|
m_Player.ProcessImGui();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WorldGridManager& WorldLevel::GetGridManager() {
|
||||||
|
return m_GridManager;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,11 @@
|
|||||||
#include "GridSystem/WorldGridManager.h"
|
#include "GridSystem/WorldGridManager.h"
|
||||||
#include "Gui/Screens/ScreenManager.h"
|
#include "Gui/Screens/ScreenManager.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
#include "OrbitingObject.h"
|
||||||
|
#include "Text.h"
|
||||||
|
#include "Gui/GuiMeter.h"
|
||||||
|
#include "Gui/Screens/MainScreen.h"
|
||||||
|
#include "Particle/Particle.h"
|
||||||
|
|
||||||
class WorldLevel : public Level
|
class WorldLevel : public Level
|
||||||
{
|
{
|
||||||
@@ -22,33 +27,38 @@ public:
|
|||||||
void MouseMove(const Vector2f& mousePos) override;
|
void MouseMove(const Vector2f& mousePos) override;
|
||||||
void ProcessImGui() override;
|
void ProcessImGui() override;
|
||||||
|
|
||||||
WorldGridManager& GetGridManager() {
|
WorldGridManager& GetGridManager();
|
||||||
return m_gridManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Collision::CollisionRect> m_Rects;
|
std::vector<Collision::CollisionRect> m_Rects;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WorldGridManager m_gridManager {};
|
double m_Fps{ 0.0f };
|
||||||
Player m_player;
|
|
||||||
Vector2f m_mousePos {};
|
|
||||||
|
|
||||||
Rectf m_viewport;
|
WorldGridManager m_GridManager;
|
||||||
|
Player m_Player;
|
||||||
|
Vector2f m_MousePos {};
|
||||||
|
|
||||||
ScreenManager* m_screenManager;
|
Rectf m_Viewport;
|
||||||
|
|
||||||
|
ScreenManager* m_ScreenManager;
|
||||||
|
|
||||||
WorldTile* m_pSelectedTile { nullptr };
|
WorldTile* m_pSelectedTile { nullptr };
|
||||||
|
|
||||||
Building* m_refeulBuilding;
|
std::vector<Building> m_Buildings{};
|
||||||
Building* m_mineralBuilding;
|
|
||||||
Building* m_junkBuilding;
|
|
||||||
Building* m_repairBuilding;
|
|
||||||
|
|
||||||
|
|
||||||
|
MainScreen* m_MainScreen{};
|
||||||
|
|
||||||
|
OrbitingObject* m_Sun{ nullptr };
|
||||||
|
OrbitingObject* m_Moon{ nullptr };
|
||||||
|
|
||||||
|
Texture* m_topCover{ nullptr };
|
||||||
|
|
||||||
// ImGui Vars
|
// ImGui Vars
|
||||||
bool m_ShowTextureManagerWindow { false };
|
bool m_ShowTextureManagerWindow { false };
|
||||||
bool m_ShowCameraWindow { false };
|
bool m_ShowCameraWindow { false };
|
||||||
bool m_ShowPlayerInfo { true };
|
bool m_ShowPlayerInfo { true };
|
||||||
|
|
||||||
bool m_FollowPlayer { false };
|
bool m_FollowPlayer { true };
|
||||||
};
|
};
|
||||||
|
|||||||
19
Game/Particle/Particle.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#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 },
|
||||||
|
m_pTexture { pTexture } {
|
||||||
|
}
|
||||||
|
void Particle::Update(float elapsedSec) {
|
||||||
|
m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
|
||||||
|
m_Velocity += m_Acceleration * elapsedSec;
|
||||||
|
m_Position += m_Velocity * elapsedSec;
|
||||||
|
m_LifeTime -= elapsedSec;
|
||||||
|
m_Acceleration = Vector2f { 0.0f, 0.0f };
|
||||||
|
|
||||||
|
}
|
||||||
|
void Particle::Draw() const {
|
||||||
|
m_pTexture->Draw(m_Position);
|
||||||
|
}
|
||||||
|
bool Particle::IsDead() const {
|
||||||
|
return m_LifeTime <= 0.0f;
|
||||||
|
}
|
||||||
20
Game/Particle/Particle.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class Particle {
|
||||||
|
public:
|
||||||
|
Particle() = default;
|
||||||
|
Particle(const Vector2f& pos, const Vector2f& velocity,float lifetime, Texture* pTexture);
|
||||||
|
void Update(float elapsedSec);
|
||||||
|
void Draw() const;
|
||||||
|
bool IsDead() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector2f m_Position;
|
||||||
|
Vector2f m_Velocity;
|
||||||
|
Vector2f m_Acceleration;
|
||||||
|
|
||||||
|
float m_LifeTime;
|
||||||
|
|
||||||
|
Texture* m_pTexture;
|
||||||
|
};
|
||||||
180
Game/Player.cpp
@@ -5,6 +5,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
#include "GridSystem/GroundTileTypeManager.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "Levels/World/WorldLevel.h"
|
#include "Levels/World/WorldLevel.h"
|
||||||
#include "Animations/Animation.h"
|
#include "Animations/Animation.h"
|
||||||
@@ -18,14 +19,28 @@ Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(P
|
|||||||
|
|
||||||
m_walkAnimation = new Animation(
|
m_walkAnimation = new Animation(
|
||||||
manager->GetTexture("animations/player/player_walk.png"),
|
manager->GetTexture("animations/player/player_walk.png"),
|
||||||
8, 0.1f, Rectf { 0, 0, 70, 70 });
|
8, 0.1f, Rectf { 0, 0, 70, 70 }, true);
|
||||||
|
m_turnAnimation = new Animation(
|
||||||
|
manager->GetTexture("animations/player/player_turn.png"),
|
||||||
|
5, 0.07f, Rectf { 0, 0, 70, 70 }, false);
|
||||||
|
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(
|
||||||
|
manager->GetTexture("animations/player/player_dig.png"),
|
||||||
|
7, 0.05f, Rectf { 0, 0, 70, 70 }, true);
|
||||||
|
|
||||||
m_currentAnimation = m_walkAnimation;
|
m_currentAnimation = m_walkAnimation;
|
||||||
}
|
}
|
||||||
|
Player::Player(Player&& other) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Player::~Player() {
|
Player::~Player() {
|
||||||
delete m_walkAnimation;
|
delete m_walkAnimation;
|
||||||
// delete m_turnAnimation;
|
delete m_turnAnimation;
|
||||||
// delete m_digAnimation;
|
delete m_digAnimation;
|
||||||
|
delete m_digStartAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collision::CollisionRect Player::GetCollisionRect() const {
|
Collision::CollisionRect Player::GetCollisionRect() const {
|
||||||
@@ -42,18 +57,29 @@ void Player::Draw() const {
|
|||||||
|
|
||||||
const int frameWidth = 70; //TODO: fix this
|
const int frameWidth = 70; //TODO: fix this
|
||||||
int halfFrameWidth = frameWidth / 2;
|
int halfFrameWidth = frameWidth / 2;
|
||||||
float bobOffset = m_BobUp ? 1 : 0;
|
int bobOffset = m_BobUp ? 1 : 0;
|
||||||
Vector2f drawPos = Vector2f { center.x - halfFrameWidth, center.y - halfFrameWidth + 9 + bobOffset };
|
|
||||||
|
|
||||||
m_walkAnimation->Draw(drawPos, Rectf { drawPos.x, drawPos.y, frameWidth, frameWidth });
|
float rotateOffset = std::abs(m_Vel.x) / 40;
|
||||||
utils::DrawEllipse(m_DigDestination, 5, 5);
|
Vector2f drawPos = Vector2f { center.x, center.y + 9 + bobOffset };
|
||||||
utils::DrawEllipse(m_DigStart, 5, 5);
|
glPushMatrix();
|
||||||
|
glTranslatef(drawPos.x - halfFrameWidth, drawPos.y - halfFrameWidth, 0);
|
||||||
|
if (!m_Grounded && std::abs(m_Vel.y) > 0.1f) {
|
||||||
|
glRotatef(m_Direction == PlayerDirection::Left ? rotateOffset : -rotateOffset, 0, 0, 1);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
m_currentAnimation->Draw(Vector2f { 0, 0 }, Rectf { 0, 0, frameWidth, frameWidth });
|
||||||
|
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
for (Particle* particle : m_DigParticles) {
|
||||||
|
particle->Draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Player::ProcessImGui() {
|
void Player::ProcessImGui() {
|
||||||
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::Text("is Grounded: %s", m_Grounded ? "true" : "false");
|
ImGui::Text("is Grounded: %s", m_Grounded ? "true" : "false");
|
||||||
ImGui::Checkbox("Draw Collision Rect", &m_DrawCollisionRect);
|
ImGui::Checkbox("Draw Collision Rect", &m_DrawCollisionRect);
|
||||||
std::string currentState {};
|
std::string currentState { "No idea" };
|
||||||
switch (m_State) {
|
switch (m_State) {
|
||||||
case PlayerState::Idle:
|
case PlayerState::Idle:
|
||||||
currentState = "Idle";
|
currentState = "Idle";
|
||||||
@@ -64,10 +90,31 @@ void Player::ProcessImGui() {
|
|||||||
case PlayerState::Walking:
|
case PlayerState::Walking:
|
||||||
currentState = "Walking";
|
currentState = "Walking";
|
||||||
break;
|
break;
|
||||||
|
case PlayerState::Flying:
|
||||||
|
currentState = "Flying";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ImGui::Text("Player State %s", currentState.c_str());
|
ImGui::Text("Player State %s", currentState.c_str());
|
||||||
|
ImGui::Text("Is digging Primed: %s", m_IsDiggingPrimed ? "true" : "false");
|
||||||
ImGui::Text("Bob counter: %f", m_BobTimer);
|
ImGui::Text("Bob counter: %f", m_BobTimer);
|
||||||
ImGui::Text("Bob up: %s", m_BobUp ? "true" : "false");
|
ImGui::Text("Bob up: %s", m_BobUp ? "true" : "false");
|
||||||
|
ImGui::Text("Is Grounded: %s", m_Grounded ? "true" : "false");
|
||||||
|
std::string direction {};
|
||||||
|
switch (m_Direction) {
|
||||||
|
case PlayerDirection::Down:
|
||||||
|
direction = "Down";
|
||||||
|
break;
|
||||||
|
case PlayerDirection::Left:
|
||||||
|
direction = "Left";
|
||||||
|
break;
|
||||||
|
case PlayerDirection::Right:
|
||||||
|
direction = "Right";
|
||||||
|
break;
|
||||||
|
case PlayerDirection::Up:
|
||||||
|
direction = "Up";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ImGui::Text("Direction: %s", direction.c_str());
|
||||||
|
|
||||||
|
|
||||||
//ContactMap
|
//ContactMap
|
||||||
@@ -91,8 +138,8 @@ void Player::Dig(Collision::CollisionDirection dir, WorldLevel& level) {
|
|||||||
//Center
|
//Center
|
||||||
m_DigDestination.x += tile->GetSize().x / 2 - m_Size.x / 2;
|
m_DigDestination.x += tile->GetSize().x / 2 - m_Size.x / 2;
|
||||||
}
|
}
|
||||||
if(dir == Collision::Left) {
|
if (dir == Collision::Left) {
|
||||||
m_DigDestination += Vector2f{ 2, 0};
|
m_DigDestination += Vector2f { 2, 0 };
|
||||||
}
|
}
|
||||||
m_ContactMap[dir] = nullptr;
|
m_ContactMap[dir] = nullptr;
|
||||||
}
|
}
|
||||||
@@ -105,7 +152,8 @@ bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) {
|
|||||||
GroundTileType type = *tile->GetTileType();
|
GroundTileType type = *tile->GetTileType();
|
||||||
//TODO: Add a list of non diggable tiles
|
//TODO: Add a list of non diggable tiles
|
||||||
|
|
||||||
if (type == Tiles::Special::HARD_LEFT || type == Tiles::Special::HARD_MIDDLE || type == Tiles::Special::HARD_RIGHT) {
|
if (type == GroundTileTypeManager::GetInstance()->HARD_LEFT || type == GroundTileTypeManager::GetInstance()->HARD_MIDDLE || type == GroundTileTypeManager::GetInstance()->
|
||||||
|
HARD_RIGHT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,29 +167,52 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
m_BobTimer = 0.0f;
|
m_BobTimer = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Particle *> particlesToDelete {};
|
||||||
|
for (Particle* particle : m_DigParticles) {
|
||||||
|
particle->Update(elapsedTime);
|
||||||
|
if (particle->IsDead()) {
|
||||||
|
particlesToDelete.push_back(particle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Particle* particle : particlesToDelete) {
|
||||||
|
m_DigParticles.erase(std::remove(m_DigParticles.begin(), m_DigParticles.end(), particle), m_DigParticles.end());
|
||||||
|
delete particle;
|
||||||
|
}
|
||||||
|
|
||||||
//check for keys
|
//check for keys
|
||||||
if (m_State != PlayerState::Digging) {
|
if (m_State != PlayerState::Digging) {
|
||||||
m_Vel = Vector2f { 0, -100 };
|
|
||||||
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
||||||
m_Vel.y = 100;
|
m_State = PlayerState::Flying;
|
||||||
|
m_Vel.y = m_Speed;
|
||||||
m_Grounded = false;
|
m_Grounded = false;
|
||||||
}
|
}
|
||||||
if (utils::isKeyPressed(SDL_SCANCODE_S)) {
|
if (utils::isKeyPressed(SDL_SCANCODE_S)) {
|
||||||
if (m_Grounded) {
|
if (m_Grounded) {
|
||||||
if (this->CanDig(Collision::Bottom, level)) {
|
if (this->CanDig(Collision::Bottom, level)) {
|
||||||
|
m_DigDirection = DigDirection::Down;
|
||||||
|
m_currentAnimation = m_digStartAnimation;
|
||||||
|
m_currentAnimation->Reset();
|
||||||
|
m_IsDiggingPrimed = false;
|
||||||
this->Dig(Collision::CollisionDirection::Bottom, level);
|
this->Dig(Collision::CollisionDirection::Bottom, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
m_Vel.y = -100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (utils::isKeyDown(SDL_SCANCODE_A)) {
|
if (utils::isKeyDown(SDL_SCANCODE_A)) {
|
||||||
|
if (!m_IsTurning) {
|
||||||
m_walkAnimation->SetFlipped(false);
|
m_walkAnimation->SetFlipped(false);
|
||||||
m_Vel.x = -100;
|
}
|
||||||
|
m_Acc.x = -m_Speed;
|
||||||
|
if (m_Direction == PlayerDirection::Right) {
|
||||||
|
m_IsTurning = true;
|
||||||
|
m_currentAnimation = m_turnAnimation;
|
||||||
|
m_currentAnimation->SetFlipped(true);
|
||||||
|
m_currentAnimation->Reset();
|
||||||
|
}
|
||||||
|
m_Direction = PlayerDirection::Left;
|
||||||
if (m_Grounded && !m_DidJustDigLeft) {
|
if (m_Grounded && !m_DidJustDigLeft) {
|
||||||
//Check if the player doesnt come from digging a tile
|
//Check if the player doesnt come from digging a tile
|
||||||
if (this->CanDig(Collision::CollisionDirection::Left, level)) {
|
if (this->CanDig(Collision::CollisionDirection::Left, level)) {
|
||||||
|
m_DigDirection = DigDirection::Left;
|
||||||
this->Dig(Collision::CollisionDirection::Left, level);
|
this->Dig(Collision::CollisionDirection::Left, level);
|
||||||
m_DidJustDigLeft = true;
|
m_DidJustDigLeft = true;
|
||||||
}
|
}
|
||||||
@@ -154,11 +225,23 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (utils::isKeyDown(SDL_SCANCODE_D)) {
|
if (utils::isKeyDown(SDL_SCANCODE_D)) {
|
||||||
m_Vel.x = 100;
|
if (!m_IsTurning) {
|
||||||
m_walkAnimation->SetFlipped(true);
|
m_walkAnimation->SetFlipped(true);
|
||||||
|
}
|
||||||
|
m_Acc.x = m_Speed;
|
||||||
|
|
||||||
|
if (m_Direction == PlayerDirection::Left) {
|
||||||
|
m_IsTurning = true;
|
||||||
|
m_currentAnimation = m_turnAnimation;
|
||||||
|
m_currentAnimation->SetFlipped(false);
|
||||||
|
m_currentAnimation->Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Direction = PlayerDirection::Right;
|
||||||
if (m_Grounded && !m_DidJustDigRight) {
|
if (m_Grounded && !m_DidJustDigRight) {
|
||||||
//Check if the player doesnt come from digging a tile
|
//Check if the player doesnt come from digging a tile
|
||||||
if (this->CanDig(Collision::CollisionDirection::Right, level)) {
|
if (this->CanDig(Collision::CollisionDirection::Right, level)) {
|
||||||
|
m_DigDirection = DigDirection::Right;
|
||||||
this->Dig(Collision::CollisionDirection::Right, level);
|
this->Dig(Collision::CollisionDirection::Right, level);
|
||||||
m_DidJustDigRight = true;
|
m_DidJustDigRight = true;
|
||||||
}
|
}
|
||||||
@@ -170,17 +253,38 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_Vel = m_Vel + m_Gravity * elapsedTime;
|
||||||
|
m_Vel = m_Vel + m_Acc * elapsedTime;
|
||||||
|
m_Vel = utils::clamp(m_Vel, Vector2f { -m_Speed, -m_Speed }, Vector2f { m_Speed, m_Speed });
|
||||||
|
|
||||||
m_walkAnimation->Update(elapsedTime);
|
//air resistance
|
||||||
|
//only if not moving
|
||||||
|
if (abs(m_Acc.x) < 0.1f) {
|
||||||
|
m_Vel.x = m_Vel.x * 0.90f;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Acc = Vector2f { 0, 0 };
|
||||||
|
|
||||||
|
|
||||||
|
m_currentAnimation->Update(elapsedTime);
|
||||||
|
|
||||||
|
if (m_currentAnimation->IsDone() && m_IsTurning) {
|
||||||
|
m_currentAnimation = m_walkAnimation;
|
||||||
|
m_IsTurning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (m_currentAnimation == m_digStartAnimation) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Collision
|
||||||
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
|
||||||
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
|
||||||
m_ContactMap[Collision::CollisionDirection::Left] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Left] = nullptr;
|
||||||
m_ContactMap[Collision::CollisionDirection::Right] = nullptr;
|
m_ContactMap[Collision::CollisionDirection::Right] = nullptr;
|
||||||
m_Grounded = false;
|
m_Grounded = false;
|
||||||
|
|
||||||
|
|
||||||
float t = 0, min_t = INFINITY;
|
float t = 0, min_t = INFINITY;
|
||||||
Vector2f intersectionPoint, normal;
|
Vector2f intersectionPoint, normal;
|
||||||
|
|
||||||
@@ -191,7 +295,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||||
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||||
WorldTile* tile = gridManager.GetTileAtIndex(x, y);
|
WorldTile* tile = gridManager.GetTileAtIndex(x, y);
|
||||||
if (*tile->GetTileType() != Tiles::AIR) {
|
if (*tile->GetTileType() != GroundTileTypeManager::GetInstance()->AIR) {
|
||||||
tile->m_Hightlight = false;
|
tile->m_Hightlight = false;
|
||||||
if (Collision::DynamicRectVsRect(this->GetCollisionRect(), elapsedTime, tile->GetCollisionRect().getCollisionRect(), intersectionPoint, normal, t)) {
|
if (Collision::DynamicRectVsRect(this->GetCollisionRect(), elapsedTime, tile->GetCollisionRect().getCollisionRect(), intersectionPoint, normal, t)) {
|
||||||
contactTimes.emplace_back(std::pair<int, float> { x + y * WORLD_WIDTH, t });
|
contactTimes.emplace_back(std::pair<int, float> { x + y * WORLD_WIDTH, t });
|
||||||
@@ -200,7 +304,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(contactTimes.begin(), contactTimes.end(), [](const std::pair<int, float>& a, const std::pair<int, float>& b) {
|
std::sort(contactTimes.begin(), contactTimes.end(), [](const std::pair<int, float>& a, const std::pair<int, float>& b)
|
||||||
|
{
|
||||||
return a.second < b.second;
|
return a.second < b.second;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -242,12 +347,14 @@ 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(); //TODO: fix this mess
|
||||||
Collision::ResolvePlayerVsRect(*this, elapsedTime, &rect);
|
Collision::ResolvePlayerVsRect(*this, elapsedTime, &rect);
|
||||||
}
|
}
|
||||||
if (m_State != PlayerState::Digging) { //Fix for when the state is JUST set to digging
|
#pragma endregion
|
||||||
if (m_Vel.x != 0.0f) {
|
|
||||||
m_State = PlayerState::Walking;
|
if (m_State == PlayerState::Walking || m_State == PlayerState::Idle) { //Fix for when the state is JUST set to digging
|
||||||
|
if (std::abs(m_Vel.x) < 0.1f) {
|
||||||
|
m_State = PlayerState::Idle;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_State = PlayerState::Idle;
|
m_State = PlayerState::Walking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,29 +366,44 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
|||||||
m_walkAnimation->SetPlaying(true);
|
m_walkAnimation->SetPlaying(true);
|
||||||
break;
|
break;
|
||||||
case PlayerState::Digging: {
|
case PlayerState::Digging: {
|
||||||
m_walkAnimation->SetPlaying(false);
|
// m_walkAnimation->SetPlaying(false);
|
||||||
//Diganimation
|
//Diganimation
|
||||||
|
m_currentAnimation->Update(elapsedTime);
|
||||||
|
if (m_currentAnimation->IsDone() && m_State == PlayerState::Digging && !m_IsDiggingPrimed) {
|
||||||
|
m_IsDiggingPrimed = true;
|
||||||
|
m_currentAnimation = m_digAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_IsDiggingPrimed) {
|
||||||
if (!m_Digging) { //TODO: fix for setting the start position
|
if (!m_Digging) { //TODO: fix for setting the start position
|
||||||
m_Digging = true;
|
m_Digging = true;
|
||||||
m_DigStart = m_Position;
|
m_DigStart = m_Position;
|
||||||
|
m_Vel = Vector2f { 0, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DigProgress += elapsedTime;
|
m_DigProgress += elapsedTime;
|
||||||
//lerp to the destination
|
//lerp to the destination
|
||||||
float progress = utils::map(m_DigProgress, 0.0f, m_DigTime, 0.0f, 1.0f);
|
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';
|
std::cout << progress << '\n';
|
||||||
|
if (particleProgress % 25 == 0) {
|
||||||
|
m_DigParticles.push_back(new Particle(m_Position, Vector2f { (float)utils::randRange(-200, 200), (float)utils::randRange(-100, -300) }, 5.f,
|
||||||
|
TextureManager::GetInstance()->GetTexture("particles/dirt_" + std::to_string(utils::randRange(1, 8)) + ".png")));
|
||||||
|
}
|
||||||
m_Position = utils::lerp(m_DigStart, m_DigDestination, progress);
|
m_Position = utils::lerp(m_DigStart, m_DigDestination, progress);
|
||||||
if (progress >= 0.5f && !m_HasDeletedTile) {
|
if (progress >= 0.5f && !m_HasDeletedTile) {
|
||||||
m_DigTile->SetTileType(Tiles::AIR);
|
m_DigTile->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
|
||||||
m_DigTile = nullptr;
|
m_DigTile = nullptr;
|
||||||
m_HasDeletedTile = true;
|
m_HasDeletedTile = true;
|
||||||
}
|
}
|
||||||
if (progress >= 1.0f) {
|
if (progress >= 1.0f) {
|
||||||
m_State = PlayerState::Idle;
|
m_State = PlayerState::Idle;
|
||||||
|
m_currentAnimation = m_walkAnimation;
|
||||||
m_HasDeletedTile = false;
|
m_HasDeletedTile = false;
|
||||||
m_Digging = false;
|
m_Digging = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Collision.h"
|
#include "Collision.h"
|
||||||
#include "TextureManager.h"
|
#include "TextureManager.h"
|
||||||
#include "Animations/Animation.h"
|
#include "Animations/Animation.h"
|
||||||
|
#include "Particle/Particle.h"
|
||||||
|
|
||||||
class WorldLevel;
|
class WorldLevel;
|
||||||
|
|
||||||
@@ -10,6 +11,8 @@ enum class PlayerState
|
|||||||
Idle,
|
Idle,
|
||||||
Walking,
|
Walking,
|
||||||
Digging,
|
Digging,
|
||||||
|
Turning,
|
||||||
|
Flying
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PlayerDirection
|
enum class PlayerDirection
|
||||||
@@ -32,7 +35,9 @@ class Player
|
|||||||
public:
|
public:
|
||||||
explicit Player(const Vector2f& Position, TextureManager* pTextureManager);
|
explicit Player(const Vector2f& Position, TextureManager* pTextureManager);
|
||||||
Player( const Player& other ) = default;
|
Player( const Player& other ) = default;
|
||||||
Player(Player&& other) = default;
|
Player(Player&& other);
|
||||||
|
Player& operator=(const Player& other) = delete;
|
||||||
|
Player& operator=(Player&& other) = delete;
|
||||||
|
|
||||||
~Player();
|
~Player();
|
||||||
|
|
||||||
@@ -72,10 +77,12 @@ private:
|
|||||||
|
|
||||||
Vector2f m_Vel;
|
Vector2f m_Vel;
|
||||||
|
|
||||||
|
const float m_Speed{ 400.0f };
|
||||||
|
|
||||||
std::map<Collision::CollisionDirection, WorldTile *> m_ContactMap;
|
std::map<Collision::CollisionDirection, WorldTile *> m_ContactMap;
|
||||||
|
|
||||||
Vector2f m_Acc;
|
Vector2f m_Acc;
|
||||||
Vector2f m_Gravity { 0, -9.81f };
|
Vector2f m_Gravity { 0, -1000.0f };
|
||||||
float m_BobTimer{ 0.0f };
|
float m_BobTimer{ 0.0f };
|
||||||
const float m_BobTime{ 0.1f };
|
const float m_BobTime{ 0.1f };
|
||||||
bool m_BobUp{ true };
|
bool m_BobUp{ true };
|
||||||
@@ -87,19 +94,25 @@ private:
|
|||||||
bool m_HasDeletedTile{ false };
|
bool m_HasDeletedTile{ false };
|
||||||
WorldTile* m_DigTile{ nullptr };
|
WorldTile* m_DigTile{ nullptr };
|
||||||
|
|
||||||
|
bool m_IsDiggingPrimed{ false };
|
||||||
|
|
||||||
|
std::vector<Particle*> m_DigParticles{};
|
||||||
|
|
||||||
const float m_DigTime{ 0.5f };
|
const float m_DigTime{ 0.5f };
|
||||||
|
|
||||||
bool m_Grounded { false };
|
bool m_Grounded { false };
|
||||||
|
bool m_IsTurning{ false };
|
||||||
|
|
||||||
bool m_DidJustDigRight { false };
|
bool m_DidJustDigRight { false };
|
||||||
bool m_DidJustDigLeft { false };
|
bool m_DidJustDigLeft { false };
|
||||||
Animation* m_currentAnimation{ nullptr };
|
Animation* m_currentAnimation{ nullptr };
|
||||||
Animation* m_walkAnimation;
|
Animation* m_walkAnimation;
|
||||||
Animation* m_turnAnimation{ nullptr };
|
Animation* m_turnAnimation{ nullptr };
|
||||||
|
Animation* m_digStartAnimation{ nullptr };
|
||||||
Animation* m_digAnimation{ nullptr };
|
Animation* m_digAnimation{ nullptr };
|
||||||
|
|
||||||
PlayerState m_State { PlayerState::Idle };
|
PlayerState m_State { PlayerState::Idle };
|
||||||
PlayerDirection m_Direction { PlayerDirection::Right };
|
PlayerDirection m_Direction { PlayerDirection::Left };
|
||||||
DigDirection m_DigDirection { DigDirection::Right };
|
DigDirection m_DigDirection { DigDirection::Right };
|
||||||
|
|
||||||
//Testing
|
//Testing
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ Texture * TextureManager::GetTexture(const std::string& name) {
|
|||||||
return pTexture;
|
return pTexture;
|
||||||
}
|
}
|
||||||
TextureManager::~TextureManager() {
|
TextureManager::~TextureManager() {
|
||||||
//TODO: Loop over the m_Textures to delete them
|
|
||||||
for (const auto& p : m_Textures) {
|
for (const auto& p : m_Textures) {
|
||||||
delete p.second;
|
delete p.second;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,21 @@
|
|||||||
|
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|
||||||
class TextureManager
|
class TextureManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static TextureManager * GetInstance();
|
static TextureManager * GetInstance();
|
||||||
static void DestroyInstance();
|
static void DestroyInstance();
|
||||||
Texture* GetTexture(const std::string& name);
|
Texture* GetTexture(const std::string& name);
|
||||||
|
|
||||||
|
TextureManager(const TextureManager& other) = delete;
|
||||||
|
TextureManager& operator=(const TextureManager& other) = delete;
|
||||||
|
TextureManager(TextureManager&& other) = delete;
|
||||||
|
TextureManager& operator=(TextureManager&& other) = delete;
|
||||||
private:
|
private:
|
||||||
TextureManager() = default;
|
TextureManager() = default;
|
||||||
~TextureManager();
|
~TextureManager();
|
||||||
|
|
||||||
static TextureManager* m_pInstance;
|
static TextureManager* m_pInstance;
|
||||||
|
|
||||||
std::map<std::string, Texture *> m_Textures {};
|
std::map<std::string, Texture *> m_Textures {};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,13 +12,10 @@ int SDL_main(int argv, char** args) {
|
|||||||
|
|
||||||
StartHeapControl();
|
StartHeapControl();
|
||||||
|
|
||||||
new Button();
|
auto pGame { new Game { Window { "Motherload - Verhulst, Bram - 1DAEGD16E", Viewport.x, Viewport.y, true} } };
|
||||||
|
|
||||||
auto pGame { new Game { Window { "Motherload - Verhulst, Bram - 1DAEGD16E", Viewport.x, Viewport.y } } };
|
|
||||||
pGame->Run();
|
pGame->Run();
|
||||||
delete pGame;
|
delete pGame;
|
||||||
|
|
||||||
//DumpMemoryLeaks();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
Resources/animations/player/player_dig.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
Resources/animations/player/player_dig_start.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Resources/animations/player/player_turn.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
BIN
Resources/fonts/Arial.ttf
Normal file
2040
Resources/gamecontrollerdb.txt
Normal file
BIN
Resources/gui/main/fuel/0.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
Resources/gui/main/fuel/10.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Resources/gui/main/fuel/100.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
Resources/gui/main/fuel/15.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
Resources/gui/main/fuel/20.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Resources/gui/main/fuel/25.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Resources/gui/main/fuel/30.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Resources/gui/main/fuel/35.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Resources/gui/main/fuel/40.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Resources/gui/main/fuel/45.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Resources/gui/main/fuel/5.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
Resources/gui/main/fuel/50.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Resources/gui/main/fuel/55.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Resources/gui/main/fuel/60.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Resources/gui/main/fuel/65.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Resources/gui/main/fuel/70.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Resources/gui/main/fuel/75.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
Resources/gui/main/fuel/80.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
Resources/gui/main/fuel/85.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
Resources/gui/main/fuel/90.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
Resources/gui/main/fuel/95.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
Resources/gui/main/fuel/fuel.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Resources/gui/main/fuel_guage.png
Normal file
|
After Width: | Height: | Size: 328 KiB |
BIN
Resources/gui/main/hull/hull.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
BIN
Resources/moon.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
Resources/particles/dirt_1.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
Resources/particles/dirt_2.png
Normal file
|
After Width: | Height: | Size: 422 B |
BIN
Resources/particles/dirt_3.png
Normal file
|
After Width: | Height: | Size: 340 B |
BIN
Resources/particles/dirt_4.png
Normal file
|
After Width: | Height: | Size: 419 B |
BIN
Resources/particles/dirt_5.png
Normal file
|
After Width: | Height: | Size: 368 B |
BIN
Resources/particles/dirt_6.png
Normal file
|
After Width: | Height: | Size: 430 B |
BIN
Resources/particles/dirt_7.png
Normal file
|
After Width: | Height: | Size: 426 B |
BIN
Resources/particles/dirt_8.png
Normal file
|
After Width: | Height: | Size: 402 B |