mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 03:41:48 +01:00
Remove Point2f, replace with Vector2f
This commit is contained in:
212
.idea/.idea.Motherload/.idea/workspace.xml
generated
212
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -10,20 +10,49 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<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="Pre Point2f Nuke Fixed drawing, Added general optimisations">
|
||||
<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/Collision.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Collision.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Collision.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Collision.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Matrix2x3.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Matrix2x3.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Matrix2x3.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Matrix2x3.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/SVGParser.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/SVGParser.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/SVGParser.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/SVGParser.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Text.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Text.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Text.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Text.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Texture.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Texture.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Texture.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Texture.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Vector2f.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Vector2f.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/Vector2f.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Vector2f.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/structs.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/structs.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/structs.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/structs.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/utils.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/utils.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/utils.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/utils.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Animations/Animation.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Animations/Animation.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Camera.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Camera.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Camera.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Camera.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Button.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Button.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Button.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Button.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screen.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screen.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/FuelScreen.cpp" beforeDir="false" 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/Levels/Level.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/Level.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/MainMenu/MainMenuLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/MainMenu/MainMenuLevel.cpp" 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/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/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/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/main.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -42,165 +71,6 @@
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Animations/Animation.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Animations/Animation.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/pch.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
@@ -233,7 +103,7 @@
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "editor.preferences.fonts.default",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode.C++",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
@@ -340,7 +210,12 @@
|
||||
<workItem from="1712830657879" duration="548000" />
|
||||
<workItem from="1713168521010" duration="1430000" />
|
||||
<workItem from="1713257719220" duration="5429000" />
|
||||
<workItem from="1713268116257" duration="1163000" />
|
||||
<workItem from="1713268116257" duration="3986000" />
|
||||
<workItem from="1713286187693" duration="2563000" />
|
||||
<workItem from="1713295701025" duration="627000" />
|
||||
<workItem from="1713336216993" duration="1172000" />
|
||||
<workItem from="1713346699128" duration="4404000" />
|
||||
<workItem from="1713354379040" duration="383000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||
<option name="closed" value="true" />
|
||||
@@ -390,7 +265,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1712360855725</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="7" />
|
||||
<task id="LOCAL-00007" summary="Pre Point2f Nuke Fixed drawing, Added general optimisations">
|
||||
<option name="closed" value="true" />
|
||||
<created>1713269323273</created>
|
||||
<option name="number" value="00007" />
|
||||
<option name="presentableId" value="LOCAL-00007" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1713269323273</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="8" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -405,7 +288,8 @@
|
||||
<MESSAGE value="Update Screen system Added FuelScreen (Working buttons) Added SellScreen (Nothing working)" />
|
||||
<MESSAGE value="Fix precompiled headers Added edge detection (if it works :/)" />
|
||||
<MESSAGE value="Fixed sidePieces (Need to add more cases tho)" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Fixed sidePieces (Need to add more cases tho)" />
|
||||
<MESSAGE value="Pre Point2f Nuke Fixed drawing, Added general optimisations" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Pre Point2f Nuke Fixed drawing, Added general optimisations" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<watches-manager>
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
namespace Collision
|
||||
{
|
||||
|
||||
TileCollisionRect::TileCollisionRect(const Point2f& pos, const Point2f& size, WorldTile* tile): pos(pos), size(size), tile(tile)
|
||||
TileCollisionRect::TileCollisionRect(const Vector2f& pos, const Vector2f& size, WorldTile* tile): pos(pos), size(size), tile(tile)
|
||||
{}
|
||||
bool PointVsRect(const Point2f p, const Collision::CollisionRect& r) {
|
||||
bool PointVsRect(const Vector2f p, const Collision::CollisionRect& r) {
|
||||
return ( p.x >= r.pos.x && p.y >= r.pos.y && p.x < r.pos.x + r.size.x && p.y < r.pos.y + r.size.y );
|
||||
}
|
||||
|
||||
@@ -17,16 +17,16 @@ namespace Collision
|
||||
return ( r1.pos.x < r2.pos.x + r2.size.x && r1.pos.x + r1.size.x > r2.pos.x && r1.pos.y < r2.pos.y + r2.size.y && r1.pos.y + r1.size.y > r2.pos.y );
|
||||
}
|
||||
|
||||
bool RayVsRect(const Point2f& rayOrigin, const Point2f& rayDirection, const Collision::CollisionRect target, Point2f& contactPoint, Point2f& contactNormal,
|
||||
bool RayVsRect(const Vector2f& rayOrigin, const Vector2f& rayDirection, const Collision::CollisionRect target, Vector2f& contactPoint, Vector2f& contactNormal,
|
||||
float& t_HitNear) {
|
||||
contactNormal = Point2f { 0, 0 };
|
||||
contactPoint = Point2f { 0, 0 };
|
||||
contactNormal = Vector2f { 0, 0 };
|
||||
contactPoint = Vector2f { 0, 0 };
|
||||
|
||||
const Point2f inverseDirection = 1.0f / rayDirection;
|
||||
const Vector2f inverseDirection = 1.0f / rayDirection;
|
||||
|
||||
// Calculate intersections with rectangle bounding axes
|
||||
Point2f t_Near = Point2f{ target.pos.x - rayOrigin.x, target.pos.y - rayOrigin.y } * inverseDirection;
|
||||
Point2f t_Far = Point2f{ target.pos.x + target.size.x - rayOrigin.x, target.pos.y + target.size.y - rayOrigin.y } * inverseDirection;
|
||||
Vector2f t_Near = Vector2f{ target.pos.x - rayOrigin.x, target.pos.y - rayOrigin.y } * inverseDirection;
|
||||
Vector2f t_Far = Vector2f{ target.pos.x + target.size.x - rayOrigin.x, target.pos.y + target.size.y - rayOrigin.y } * inverseDirection;
|
||||
|
||||
if (std::isnan(t_Far.y) || std::isnan(t_Far.x))
|
||||
return false;
|
||||
@@ -57,18 +57,18 @@ namespace Collision
|
||||
|
||||
if (t_Near.x > t_Near.y) {
|
||||
if (inverseDirection.x < 0) {
|
||||
contactNormal = Point2f { 1, 0 };
|
||||
contactNormal = Vector2f { 1, 0 };
|
||||
}
|
||||
else {
|
||||
contactNormal = Point2f { -1, 0 };
|
||||
contactNormal = Vector2f { -1, 0 };
|
||||
}
|
||||
}
|
||||
else if (t_Near.x < t_Near.y) {
|
||||
if (inverseDirection.y < 0) {
|
||||
contactNormal = Point2f { 0, 1 };
|
||||
contactNormal = Vector2f { 0, 1 };
|
||||
}
|
||||
else {
|
||||
contactNormal = Point2f { 0, -1 };
|
||||
contactNormal = Vector2f { 0, -1 };
|
||||
}
|
||||
}
|
||||
// If t_Near == t_Far, collision is diagonal so pointless
|
||||
@@ -77,7 +77,7 @@ namespace Collision
|
||||
}
|
||||
|
||||
bool DynamicRectVsRect(const Collision::CollisionRect& dynamicRectangle, float ElapsedTime, const Collision::CollisionRect& staticRectangle,
|
||||
Point2f& contactPoint, Point2f& contactNormal, float& contactTime) {
|
||||
Vector2f& contactPoint, Vector2f& contactNormal, float& contactTime) {
|
||||
// Check if dynamic rectangle is actually moving - we assume rectangles are NOT in collision to start
|
||||
if (dynamicRectangle.vel.x == 0 && dynamicRectangle.vel.y == 0) {
|
||||
return false;
|
||||
@@ -85,10 +85,10 @@ namespace Collision
|
||||
|
||||
// Expand target rectangle by source dimensions
|
||||
Collision::CollisionRect expandedTarget;
|
||||
expandedTarget.pos = Point2f{staticRectangle.pos.x - (dynamicRectangle.size / 2).x, staticRectangle.pos.y - (dynamicRectangle.size / 2).y};
|
||||
expandedTarget.pos = Vector2f{staticRectangle.pos.x - (dynamicRectangle.size / 2).x, staticRectangle.pos.y - (dynamicRectangle.size / 2).y};
|
||||
expandedTarget.size = staticRectangle.size + dynamicRectangle.size;
|
||||
|
||||
Point2f RayOrigin = dynamicRectangle.pos + dynamicRectangle.size / 2;
|
||||
Vector2f RayOrigin = dynamicRectangle.pos + dynamicRectangle.size / 2;
|
||||
|
||||
if (RayVsRect(RayOrigin, dynamicRectangle.vel * ElapsedTime, expandedTarget, contactPoint, contactNormal, contactTime)) {
|
||||
return ( contactTime >= 0.0f && contactTime < 1.0f );
|
||||
@@ -100,7 +100,7 @@ namespace Collision
|
||||
}
|
||||
|
||||
bool ResolveDynamicRectVsRect(Collision::CollisionRect& dynamicRectangle, float ElapsedTime, Collision::CollisionRect* staticRectangle) {
|
||||
Point2f contactPoint, contactNormal;
|
||||
Vector2f contactPoint, contactNormal;
|
||||
float contact_time = 0.0f;
|
||||
if (DynamicRectVsRect(dynamicRectangle, ElapsedTime, *staticRectangle, contactPoint, contactNormal, contact_time)) {
|
||||
if (contactNormal.y > 0) {
|
||||
@@ -116,7 +116,7 @@ namespace Collision
|
||||
dynamicRectangle.ContactMap[CollisionDirection::Left] = staticRectangle;
|
||||
}
|
||||
|
||||
//dynamicRectangle.vel = dynamicRectangle.vel + contactNormal * Point2f(std::abs(dynamicRectangle.vel.x), std::abs(dynamicRectangle.vel.y)) * ( 1 - contact_time );
|
||||
//dynamicRectangle.vel = dynamicRectangle.vel + contactNormal * Vector2f(std::abs(dynamicRectangle.vel.x), std::abs(dynamicRectangle.vel.y)) * ( 1 - contact_time );
|
||||
dynamicRectangle.vel = dynamicRectangle.vel + contactNormal * -utils::DotProduct(dynamicRectangle.vel, contactNormal) * ( 1 - contact_time );
|
||||
return true;
|
||||
}
|
||||
@@ -126,7 +126,6 @@ namespace Collision
|
||||
bool ResolvePlayerVsRect(Player& player, float ElapsedTime, Collision::CollisionRect* staticRectangle) {
|
||||
CollisionRect rect = player.GetCollisionRect();
|
||||
Collision::ResolveDynamicRectVsRect(rect, ElapsedTime, staticRectangle);
|
||||
|
||||
|
||||
player.SetPosition(rect.pos);
|
||||
player.SetVelocity(rect.vel);
|
||||
|
||||
@@ -22,25 +22,25 @@ namespace Collision
|
||||
struct CollisionRect
|
||||
{
|
||||
CollisionRect() = default;
|
||||
CollisionRect(const Point2f& pos, const Point2f& size) : pos(pos), size(size) {}
|
||||
CollisionRect(const Point2f& pos, const Point2f& size, const Point2f& vel) : pos(pos), size(size), vel(vel) {}
|
||||
Point2f pos;
|
||||
Point2f size;
|
||||
Point2f vel;
|
||||
CollisionRect(const Vector2f& pos, const Vector2f& size) : pos(pos), size(size) {}
|
||||
CollisionRect(const Vector2f& pos, const Vector2f& size, const Vector2f& vel) : pos(pos), size(size), vel(vel) {}
|
||||
Vector2f pos;
|
||||
Vector2f size;
|
||||
Vector2f vel;
|
||||
|
||||
std::map<CollisionDirection, CollisionRect*> ContactMap{};
|
||||
};
|
||||
|
||||
struct TileCollisionRect
|
||||
{
|
||||
Point2f pos;
|
||||
Point2f size;
|
||||
Point2f vel;
|
||||
Vector2f pos;
|
||||
Vector2f size;
|
||||
Vector2f vel;
|
||||
|
||||
TileCollisionRect(const Point2f& pos, const Point2f& size, WorldTile* tile);
|
||||
TileCollisionRect(const Vector2f& pos, const Vector2f& size, WorldTile* tile);
|
||||
WorldTile* tile;
|
||||
|
||||
bool Contains(Point2f point2_f) {
|
||||
bool Contains(Vector2f point2_f) {
|
||||
return utils::IsPointInRect(point2_f, Rectf{ pos.x, pos.y, size.x, size.y });
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ namespace Collision
|
||||
}
|
||||
};
|
||||
|
||||
bool PointVsRect(const Point2f p, const CollisionRect& r);
|
||||
bool PointVsRect(const Vector2f p, const CollisionRect& r);
|
||||
|
||||
bool RectVsRect(const CollisionRect& r1, const CollisionRect r2);
|
||||
|
||||
bool RayVsRect(const Point2f& rayOrigin, const Point2f& rayDirection, const Collision::CollisionRect target, Point2f& contactPoint, Point2f& contactNormal, float& t_HitNear);
|
||||
bool RayVsRect(const Vector2f& rayOrigin, const Vector2f& rayDirection, const Collision::CollisionRect target, Vector2f& contactPoint, Vector2f& contactNormal, float& t_HitNear);
|
||||
|
||||
bool DynamicRectVsRect(const CollisionRect& dynamicRectangle, float ElapsedTime, const CollisionRect& staticRectangle, Point2f& contactPoint, Point2f& contactNormal, float& contactTime);
|
||||
bool DynamicRectVsRect(const CollisionRect& dynamicRectangle, float ElapsedTime, const CollisionRect& staticRectangle, Vector2f& contactPoint, Vector2f& contactNormal, float& contactTime);
|
||||
|
||||
bool ResolveDynamicRectVsRect(CollisionRect& dynamicRectangle, float ElapsedTime, CollisionRect* staticRectangle);
|
||||
|
||||
|
||||
@@ -18,35 +18,29 @@ Vector2f Matrix2x3::Transform(const Vector2f& vector) const
|
||||
return Vector2f{ vector.x * dirX + vector.y * dirY };
|
||||
}
|
||||
|
||||
Point2f Matrix2x3::Transform(const Point2f& point) const
|
||||
std::vector<Vector2f> Matrix2x3::Transform(const Rectf & r) const
|
||||
{
|
||||
Vector2f v{ Transform( Vector2f{ point } ) + orig };
|
||||
return v.ToPoint2f();
|
||||
}
|
||||
|
||||
std::vector<Point2f> Matrix2x3::Transform(const Rectf & r) const
|
||||
{
|
||||
std::vector<Point2f> vertices{ 4 };
|
||||
vertices[0] = Transform( Point2f{ r.left, r.bottom } );
|
||||
vertices[1] = Transform( Point2f{ r.left, r.bottom + r.height } );
|
||||
vertices[2] = Transform( Point2f{ r.left + r.width, r.bottom + r.height } );
|
||||
vertices[3] = Transform( Point2f{ r.left + r.width, r.bottom } );
|
||||
std::vector<Vector2f> vertices{ 4 };
|
||||
vertices[0] = Transform( Vector2f{ r.left, r.bottom } );
|
||||
vertices[1] = Transform( Vector2f{ r.left, r.bottom + r.height } );
|
||||
vertices[2] = Transform( Vector2f{ r.left + r.width, r.bottom + r.height } );
|
||||
vertices[3] = Transform( Vector2f{ r.left + r.width, r.bottom } );
|
||||
return vertices;
|
||||
}
|
||||
|
||||
void Matrix2x3::Transform( const Rectf& r, Point2f* transVertices ) const
|
||||
void Matrix2x3::Transform( const Rectf& r, Vector2f* transVertices ) const
|
||||
{
|
||||
transVertices[0] = Transform( Point2f{ r.left, r.bottom } );
|
||||
transVertices[1] = Transform( Point2f{ r.left, r.bottom + r.height } );
|
||||
transVertices[2] = Transform( Point2f{ r.left + r.width, r.bottom + r.height } );
|
||||
transVertices[3] = Transform( Point2f{ r.left + r.width, r.bottom } );
|
||||
transVertices[0] = Transform( Vector2f{ r.left, r.bottom } );
|
||||
transVertices[1] = Transform( Vector2f{ r.left, r.bottom + r.height } );
|
||||
transVertices[2] = Transform( Vector2f{ r.left + r.width, r.bottom + r.height } );
|
||||
transVertices[3] = Transform( Vector2f{ r.left + r.width, r.bottom } );
|
||||
}
|
||||
|
||||
|
||||
std::vector<Point2f> Matrix2x3::Transform( const std::vector<Point2f>& vertices ) const
|
||||
std::vector<Vector2f> Matrix2x3::Transform( const std::vector<Vector2f>& vertices ) const
|
||||
{
|
||||
size_t nrVectices{ vertices.size( ) };
|
||||
std::vector<Point2f> transformedVertices{ nrVectices };
|
||||
std::vector<Vector2f> transformedVertices{ nrVectices };
|
||||
for ( size_t idx{ 0 }; idx < nrVectices; ++idx )
|
||||
{
|
||||
transformedVertices[idx] = Transform( vertices[idx] );
|
||||
@@ -54,13 +48,13 @@ std::vector<Point2f> Matrix2x3::Transform( const std::vector<Point2f>& vertices
|
||||
return transformedVertices;
|
||||
}
|
||||
|
||||
void Matrix2x3::Transform( const std::vector<Point2f>& vertices, Point2f* transVertices ) const
|
||||
void Matrix2x3::Transform( const std::vector<Vector2f>& vertices, Vector2f* transVertices ) const
|
||||
{
|
||||
Transform( vertices.data( ), transVertices, vertices.size( ) );
|
||||
}
|
||||
|
||||
|
||||
void Matrix2x3::Transform( const Point2f* vertices, Point2f* transVertices, size_t nrVertices ) const
|
||||
void Matrix2x3::Transform( const Vector2f* vertices, Vector2f* transVertices, size_t nrVertices ) const
|
||||
{
|
||||
for ( size_t idx{ 0 }; idx < nrVertices; ++idx )
|
||||
{
|
||||
|
||||
@@ -19,35 +19,31 @@ struct Matrix2x3 final
|
||||
// Vector2f vTransformed = mat.Transform(v);
|
||||
Vector2f Transform( const Vector2f& v ) const;
|
||||
|
||||
// Transform a point by this matrix, including translation
|
||||
// Point2f pTransformed = mat.Transform(p);
|
||||
Point2f Transform( const Point2f& p ) const;
|
||||
|
||||
// Transform a Rectf by this matrix, including translation
|
||||
// std::vector<Point2f> transformedVertices = mat.Transform(r);
|
||||
std::vector<Point2f> Transform( const Rectf& r ) const;
|
||||
// std::vector<Vector2f> transformedVertices = mat.Transform(r);
|
||||
std::vector<Vector2f> Transform( const Rectf& r ) const;
|
||||
|
||||
|
||||
// Transform a Rectf by this matrix, including translation
|
||||
// Pass pointer to resulting array (size should be at least 4)
|
||||
// Point2f transformedVertices[4];
|
||||
// Vector2f transformedVertices[4];
|
||||
// Transform(r, transformedVertices);
|
||||
void Transform( const Rectf& r, Point2f* transVertices ) const;
|
||||
void Transform( const Rectf& r, Vector2f* transVertices ) const;
|
||||
|
||||
// Transform a Polygon by this matrix, including translation
|
||||
// std::vector<Point2f> transformedVertices = mat.Transform(vertices);
|
||||
std::vector<Point2f> Transform( const std::vector<Point2f>& vertices ) const;
|
||||
// std::vector<Vector2f> transformedVertices = mat.Transform(vertices);
|
||||
std::vector<Vector2f> Transform( const std::vector<Vector2f>& vertices ) const;
|
||||
|
||||
// Transform a Polygon by this matrix, including translation
|
||||
// Pass pointer to resulting array (size should be at least size of polygon)
|
||||
// Point2f transformedVertices[vertices.size()];
|
||||
// Vector2f transformedVertices[vertices.size()];
|
||||
// Transform(vertices, transformedVertices);
|
||||
void Transform( const std::vector<Point2f>& vertices, Point2f* transVertices ) const;
|
||||
void Transform( const std::vector<Vector2f>& vertices, Vector2f* transVertices ) const;
|
||||
|
||||
// Transform a Polygon by this matrix, including translation
|
||||
// Point2f transformedVertices[nrVertices];
|
||||
// Vector2f transformedVertices[nrVertices];
|
||||
// Transform(vertices, nrVertices, transformedVertices);
|
||||
void Transform( const Point2f* vertices, Point2f* transVertices, size_t nrVertices ) const;
|
||||
void Transform( const Vector2f* vertices, Vector2f* transVertices, size_t nrVertices ) const;
|
||||
|
||||
// Calculate the determinant
|
||||
float Determinant( ) const;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <fstream>
|
||||
#include "SVGParser.h"
|
||||
|
||||
bool SVGParser::GetVerticesFromSvgFile( const std::string& filePath, std::vector<std::vector<Point2f>> &vertices )
|
||||
bool SVGParser::GetVerticesFromSvgFile( const std::string& filePath, std::vector<std::vector<Vector2f>> &vertices )
|
||||
{
|
||||
// Open the file
|
||||
std::ifstream svgStream( filePath.c_str( ) );
|
||||
@@ -49,11 +49,11 @@ bool SVGParser::GetVerticesFromSvgFile( const std::string& filePath, std::vector
|
||||
std::stringstream sstream{ viewBoxValue };
|
||||
sstream >> viewBox.left >> viewBox.bottom >> viewBox.width >> viewBox.height;
|
||||
|
||||
//std::vector<std::vector<Point2f>> vertices{ vertices };
|
||||
//std::vector<std::vector<Vector2f>> vertices{ vertices };
|
||||
for (size_t i{}; i < vertices.size(); ++i)
|
||||
{
|
||||
// flip the y coordinate
|
||||
for (Point2f& p : vertices[i])
|
||||
for (Vector2f& p : vertices[i])
|
||||
{
|
||||
p.y = viewBox.height - p.y;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ void SVGParser::RemoveSpaces( std::string& svgString )
|
||||
|
||||
}
|
||||
|
||||
bool SVGParser::GetVerticesFromSvgString(std::string& svgString, std::vector<std::vector<Point2f>> &vertices)
|
||||
bool SVGParser::GetVerticesFromSvgString(std::string& svgString, std::vector<std::vector<Vector2f>> &vertices)
|
||||
{
|
||||
size_t startPosContent{};
|
||||
size_t endPosContent{};
|
||||
@@ -102,8 +102,8 @@ bool SVGParser::GetVerticesFromSvgString(std::string& svgString, std::vector<std
|
||||
// Get path element until none has been found anymore
|
||||
while (GetElementContent(svgString, "path", pathElementContent, startPosContent, endPosContent))
|
||||
{
|
||||
// Vector of Point2f to fill with a path's vertices
|
||||
std::vector<Point2f> verticesVector;
|
||||
// Vector of Vector2f to fill with a path's vertices
|
||||
std::vector<Vector2f> verticesVector;
|
||||
|
||||
// Get d attribute value
|
||||
std::string pathDataValue{};
|
||||
@@ -130,7 +130,7 @@ bool SVGParser::GetVerticesFromSvgString(std::string& svgString, std::vector<std
|
||||
}
|
||||
|
||||
// DEBUG: Read vertices of current vector
|
||||
//for (Point2f& p : verticesVector)
|
||||
//for (Vector2f& p : verticesVector)
|
||||
//{
|
||||
// std::cout << p.x << " " << p.y << std::endl;
|
||||
//}
|
||||
@@ -148,7 +148,7 @@ bool SVGParser::GetVerticesFromSvgString(std::string& svgString, std::vector<std
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVGParser::GetVerticesFromPathData( const std::string& pathData, std::vector<Point2f> &vertices )
|
||||
bool SVGParser::GetVerticesFromPathData( const std::string& pathData, std::vector<Vector2f> &vertices )
|
||||
{
|
||||
std::string pathCmdChars( ( "mMZzLlHhVvCcSsQqTtAa" ) );
|
||||
|
||||
@@ -156,13 +156,13 @@ bool SVGParser::GetVerticesFromPathData( const std::string& pathData, std::vecto
|
||||
std::stringstream ss( pathData );
|
||||
|
||||
char cmd{ 0 };
|
||||
Point2f cursor{};
|
||||
Point2f startPoint{};//At the end of the z command, the new current point is set to the initial point of the current subpath.
|
||||
Vector2f cursor{};
|
||||
Vector2f startPoint{};//At the end of the z command, the new current point is set to the initial point of the current subpath.
|
||||
|
||||
bool isOpen = true;
|
||||
|
||||
// http://www.w3.org/TR/SVG/paths.html#Introduction
|
||||
Point2f vertex{};
|
||||
Vector2f vertex{};
|
||||
char pathCommand{};
|
||||
ss >> pathCommand;
|
||||
while ( !ss.eof( ) )
|
||||
@@ -370,23 +370,23 @@ float SVGParser::ReadSvgValue( std::stringstream& svgStream, bool separatorRequi
|
||||
}
|
||||
|
||||
// Reads a single point
|
||||
Point2f SVGParser::ReadSvgPoint( std::stringstream& svgStream )
|
||||
Vector2f SVGParser::ReadSvgPoint( std::stringstream& svgStream )
|
||||
{
|
||||
//std::cout << "ReadSvgPoint: " << svgStream.str() << "\n";
|
||||
Point2f p{};
|
||||
Vector2f p{};
|
||||
p.x = ReadSvgValue( svgStream, true );
|
||||
p.y = ReadSvgValue( svgStream, false );
|
||||
return p;
|
||||
}
|
||||
|
||||
Point2f SVGParser::FirstSvgPoint( std::stringstream& svgStream, Point2f& cursor, char cmd, bool isOpen, bool advance )
|
||||
Vector2f SVGParser::FirstSvgPoint( std::stringstream& svgStream, Vector2f& cursor, char cmd, bool isOpen, bool advance )
|
||||
{
|
||||
if ( !isOpen )
|
||||
{
|
||||
std::cerr << "SVGParser::FirstSvgPoint, expected 'Z' or 'z' command";
|
||||
}
|
||||
|
||||
Point2f p = ReadSvgPoint( svgStream );
|
||||
Vector2f p = ReadSvgPoint( svgStream );
|
||||
|
||||
if ( islower( cmd ) )
|
||||
{
|
||||
@@ -406,14 +406,14 @@ Point2f SVGParser::FirstSvgPoint( std::stringstream& svgStream, Point2f& cursor,
|
||||
// taking into account relative and absolute positioning.
|
||||
// Advances the cursor if requested.
|
||||
// Throws an exception if the figure is not open
|
||||
Point2f SVGParser::NextSvgPoint( std::stringstream& svgStream, Point2f& cursor, char cmd, bool isOpen, bool advance )
|
||||
Vector2f SVGParser::NextSvgPoint( std::stringstream& svgStream, Vector2f& cursor, char cmd, bool isOpen, bool advance )
|
||||
{
|
||||
if ( isOpen )
|
||||
{
|
||||
std::cerr << "SVGParser::NextSvgPoint, expected 'M' or 'm' command\n";
|
||||
}
|
||||
|
||||
Point2f p = ReadSvgPoint( svgStream );
|
||||
Vector2f p = ReadSvgPoint( svgStream );
|
||||
|
||||
if ( islower( cmd ) )
|
||||
{
|
||||
@@ -431,7 +431,7 @@ Point2f SVGParser::NextSvgPoint( std::stringstream& svgStream, Point2f& cursor,
|
||||
}
|
||||
|
||||
// Reads next point, given only the new x coordinate
|
||||
Point2f SVGParser::NextSvgCoordX( std::stringstream& svgStream, Point2f& cursor, char cmd, bool isOpen )
|
||||
Vector2f SVGParser::NextSvgCoordX( std::stringstream& svgStream, Vector2f& cursor, char cmd, bool isOpen )
|
||||
{
|
||||
if ( isOpen )
|
||||
{
|
||||
@@ -455,7 +455,7 @@ Point2f SVGParser::NextSvgCoordX( std::stringstream& svgStream, Point2f& cursor,
|
||||
}
|
||||
|
||||
// Reads next point, given only the new y coordinate
|
||||
Point2f SVGParser::NextSvgCoordY( std::stringstream& svgStream, Point2f& cursor, char cmd, bool isOpen )
|
||||
Vector2f SVGParser::NextSvgCoordY( std::stringstream& svgStream, Vector2f& cursor, char cmd, bool isOpen )
|
||||
{
|
||||
if ( isOpen )
|
||||
{
|
||||
|
||||
@@ -7,13 +7,13 @@ class SVGParser final
|
||||
{
|
||||
public:
|
||||
// The only function to be called
|
||||
static bool GetVerticesFromSvgFile(const std::string& filePath, std::vector<std::vector<Point2f>> &vertices);
|
||||
static bool GetVerticesFromSvgFile(const std::string& filePath, std::vector<std::vector<Vector2f>> &vertices);
|
||||
|
||||
private:
|
||||
//static bool LoadGeometryFromSvgStream(unsigned char* pBlob, int blobSize, std::vector<Point2f> &vertices);
|
||||
//static bool LoadGeometryFromSvgStream(unsigned char* pBlob, int blobSize, std::vector<Vector2f> &vertices);
|
||||
static void RemoveSpaces( std::string& svgString );
|
||||
static bool GetVerticesFromSvgString(std::string& svgText, std::vector<std::vector<Point2f>> &vertices);
|
||||
static bool GetVerticesFromPathData( const std::string& pathData, std::vector<Point2f> &vertices );
|
||||
static bool GetVerticesFromSvgString(std::string& svgText, std::vector<std::vector<Vector2f>> &vertices);
|
||||
static bool GetVerticesFromPathData( const std::string& pathData, std::vector<Vector2f> &vertices );
|
||||
static bool GetElementContent( const std::string& svgText, const std::string& elementName, std::string& elementValue, size_t& startContentPos, size_t& endContentPos);
|
||||
static bool GetAttributeValue( const std::string& svgText, const std::string& attributeName, std::string& attributeValue );
|
||||
|
||||
@@ -27,23 +27,23 @@ private:
|
||||
static float ReadSvgValue(std::stringstream& stream, bool separatorRequired);
|
||||
|
||||
// Reads a single point
|
||||
static Point2f ReadSvgPoint( std::stringstream& stream );
|
||||
static Vector2f ReadSvgPoint( std::stringstream& stream );
|
||||
|
||||
// Read the first point,
|
||||
// taking into account relative and absolute positioning.
|
||||
// Stores this point, needed when path is closed
|
||||
// Advances the cursor if requested.
|
||||
static Point2f FirstSvgPoint(std::stringstream& stream, Point2f& cursor, char cmd, bool isOpen, bool advance);
|
||||
static Vector2f FirstSvgPoint(std::stringstream& stream, Vector2f& cursor, char cmd, bool isOpen, bool advance);
|
||||
|
||||
// Read the next point,
|
||||
// taking into account relative and absolute positioning.
|
||||
// Advances the cursor if requested.
|
||||
// Throws an exception if the figure is not open
|
||||
static Point2f NextSvgPoint(std::stringstream& stream, Point2f& cursor, char cmd, bool isOpen, bool advance);
|
||||
static Vector2f NextSvgPoint(std::stringstream& stream, Vector2f& cursor, char cmd, bool isOpen, bool advance);
|
||||
|
||||
// Reads next point, given only the new x coordinate
|
||||
static Point2f NextSvgCoordX(std::stringstream& stream, Point2f& cursor, char cmd, bool isOpen);
|
||||
static Vector2f NextSvgCoordX(std::stringstream& stream, Vector2f& cursor, char cmd, bool isOpen);
|
||||
|
||||
// Reads next point, given only the new y coordinate
|
||||
static Point2f NextSvgCoordY(std::stringstream& ssRef, Point2f& cursor, char cmd, bool isOpen);
|
||||
static Vector2f NextSvgCoordY(std::stringstream& ssRef, Vector2f& cursor, char cmd, bool isOpen);
|
||||
};
|
||||
|
||||
@@ -12,6 +12,6 @@ Text::~Text() {
|
||||
if(m_IsCreatedOk && m_Texture->IsCreationOk()) {
|
||||
}
|
||||
}
|
||||
void Text::Draw(const Point2f& pos) const {
|
||||
void Text::Draw(const Vector2f& pos) const {
|
||||
m_Texture->Draw(pos);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
Text() = default;
|
||||
~Text();
|
||||
|
||||
void Draw(const Point2f& pos) const;
|
||||
void Draw(const Vector2f& pos) const;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ void Texture::CreateFromSurface( SDL_Surface* pSurface )
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
}
|
||||
|
||||
void Texture::Draw( const Point2f& dstBottomLeft, const Rectf& srcRect, bool flip) const
|
||||
void Texture::Draw( const Vector2f& dstBottomLeft, const Rectf& srcRect, bool flip) const
|
||||
{
|
||||
const float epsilon{ 0.001f };
|
||||
if ( !m_CreationOk )
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
Texture& operator=( Texture&& other ) noexcept;
|
||||
~Texture();
|
||||
|
||||
void Draw(const Point2f& dstBottomLeft = {}, const Rectf& srcRect = {}, bool flip = false) const;
|
||||
void Draw(const Vector2f& dstBottomLeft = {}, const Rectf& srcRect = {}, bool flip = false) const;
|
||||
void Draw( const Rectf& dstRect, const Rectf& srcRect = {}, bool flip = false) const;
|
||||
|
||||
float GetWidth() const;
|
||||
|
||||
@@ -19,16 +19,14 @@ Vector2f::Vector2f( float x, float y )
|
||||
, y{ y }
|
||||
{
|
||||
}
|
||||
|
||||
Vector2f::Vector2f( const Point2f& fromPoint, const Point2f& tillPoint )
|
||||
Vector2f::Vector2f( const Vector2f& fromPoint, const Vector2f& tillPoint )
|
||||
: Vector2f{ tillPoint.x - fromPoint.x, tillPoint.y - fromPoint.y }
|
||||
{
|
||||
}
|
||||
|
||||
Vector2f::Vector2f(const Point2f & point)
|
||||
: Vector2f{ Point2f{ 0.0f, 0.0f }, point }
|
||||
{
|
||||
}
|
||||
// Vector2f::Vector2f(const Vector2f & point)
|
||||
// : Vector2f{ Vector2f{ 0.0f, 0.0f }, point }
|
||||
// {
|
||||
// }
|
||||
|
||||
// -------------------------
|
||||
// Methods
|
||||
@@ -38,11 +36,6 @@ bool Vector2f::Equals(const Vector2f& other, float epsilon) const
|
||||
return ( abs(x - other.x) < epsilon ) && ( abs(y - other.y) < epsilon );
|
||||
}
|
||||
|
||||
Point2f Vector2f::ToPoint2f() const
|
||||
{
|
||||
return Point2f{ x, y };
|
||||
}
|
||||
|
||||
float Vector2f::DotProduct(const Vector2f& other) const
|
||||
{
|
||||
return x * other.x + y * other.y;
|
||||
@@ -113,6 +106,9 @@ void Vector2f::Set(float newX, float newY)
|
||||
x = newX;
|
||||
y = newY;
|
||||
}
|
||||
Vector2f Vector2f::operator*(const Vector2f& vector2_f) const {
|
||||
return Vector2f{ x * vector2_f.x, y * vector2_f.y };
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Member operators
|
||||
@@ -151,12 +147,6 @@ Vector2f& Vector2f::operator-=(const Vector2f& rhs)
|
||||
*this += -rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2f::operator Point2f()
|
||||
{
|
||||
return Point2f{ x,y };
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Non-member operators
|
||||
// -------------------------
|
||||
@@ -174,6 +164,9 @@ Vector2f operator/( Vector2f lhs, float rhs )
|
||||
{
|
||||
return lhs *= (1 / rhs);
|
||||
}
|
||||
Vector2f operator/(float lhs, const Vector2f& rhs) {
|
||||
return Vector2f{ lhs / rhs.x, lhs / rhs.y };
|
||||
}
|
||||
|
||||
Vector2f operator+( Vector2f lhs, const Vector2f& rhs )
|
||||
{
|
||||
@@ -199,38 +192,4 @@ std::ostream& operator<< ( std::ostream& lhs, const Vector2f& rhs )
|
||||
{
|
||||
lhs << rhs.ToString( );
|
||||
return lhs;
|
||||
}
|
||||
|
||||
// Point2f related operators
|
||||
Point2f& operator+=(Point2f& lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs.x += rhs.x;
|
||||
lhs.y += rhs.y;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Point2f operator+(Point2f lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Point2f& operator-=(Point2f& lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs.x -= rhs.x;
|
||||
lhs.y -= rhs.y;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Point2f operator-(Point2f lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
||||
Vector2f operator-(const Point2f& lhs, const Point2f& rhs)
|
||||
{
|
||||
Vector2f v{ lhs.x - rhs.x, lhs.y - rhs.y };
|
||||
return v;
|
||||
}
|
||||
@@ -8,26 +8,25 @@ struct Vector2f final
|
||||
// -------------------------
|
||||
Vector2f( );
|
||||
explicit Vector2f( float x, float y );
|
||||
explicit Vector2f( const Point2f& fromPoint, const Point2f& tillPoint );
|
||||
explicit Vector2f( const Point2f& point );
|
||||
explicit Vector2f( const Vector2f& fromPoint, const Vector2f& tillPoint );
|
||||
// explicit Vector2f( const Vector2f& point );
|
||||
|
||||
// -------------------------
|
||||
// Member operators
|
||||
// -------------------------
|
||||
Vector2f operator-( ) const;
|
||||
Vector2f operator+( ) const;
|
||||
Vector2f& operator*=( float rhs);
|
||||
Vector2f& operator/=( float rhs);
|
||||
Vector2f& operator+=( const Vector2f& rhs);
|
||||
Vector2f& operator-=( const Vector2f& rhs);
|
||||
explicit operator Point2f();
|
||||
|
||||
|
||||
Vector2f& operator*=( float rhs);
|
||||
Vector2f& operator/=( float rhs);
|
||||
|
||||
|
||||
// -------------------------
|
||||
// Methods
|
||||
// -------------------------
|
||||
// Convert to Point2f
|
||||
Point2f ToPoint2f( ) const;
|
||||
|
||||
// Are two vectors equal within a threshold?
|
||||
// u.Equals(v)
|
||||
bool Equals( const Vector2f& other, float epsilon = 0.001f ) const;
|
||||
@@ -75,6 +74,7 @@ struct Vector2f final
|
||||
|
||||
// Sets the values of x and y
|
||||
void Set( float newX, float newY );
|
||||
Vector2f operator*(const Vector2f& vector2_f) const;
|
||||
|
||||
// -------------------------
|
||||
// Datamembers
|
||||
@@ -88,6 +88,8 @@ struct Vector2f final
|
||||
Vector2f operator*( float lhs, Vector2f rhs );
|
||||
Vector2f operator*( Vector2f lhs, float rhs );
|
||||
Vector2f operator/( Vector2f lhs, float rhs );
|
||||
Vector2f operator/(float lhs, const Vector2f& rhs);
|
||||
|
||||
|
||||
Vector2f operator+( Vector2f lhs, const Vector2f& rhs );
|
||||
Vector2f operator-( Vector2f lhs, const Vector2f& rhs );
|
||||
@@ -95,15 +97,4 @@ Vector2f operator-( Vector2f lhs, const Vector2f& rhs );
|
||||
bool operator==( const Vector2f& lhs, const Vector2f& rhs );
|
||||
bool operator!=( const Vector2f& lhs, const Vector2f& rhs );
|
||||
|
||||
std::ostream& operator<< ( std::ostream& lhs, const Vector2f& rhs );
|
||||
|
||||
// Translating a point by a vector
|
||||
Point2f& operator+=(Point2f& lhs, const Vector2f& rhs);
|
||||
Point2f operator+(Point2f lhs, const Vector2f& rhs);
|
||||
|
||||
Point2f& operator-=(Point2f& lhs, const Vector2f& rhs);
|
||||
Point2f operator-(Point2f lhs, const Vector2f& rhs);
|
||||
|
||||
// The difference vector between 2 points
|
||||
Vector2f operator-( const Point2f& lhs, const Point2f& rhs);
|
||||
|
||||
std::ostream& operator<< ( std::ostream& lhs, const Vector2f& rhs );
|
||||
@@ -14,50 +14,50 @@ Window::Window(const std::string& title, float width, float height, bool isVSync
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Point2f Constructors
|
||||
// Vector2f Constructors
|
||||
//-----------------------------------------------------------------
|
||||
Point2f::Point2f()
|
||||
: Point2f { 0.0f, 0.0f } {
|
||||
}
|
||||
Point2f::Point2f(float x, float y)
|
||||
: x { x }, y { y } {
|
||||
}
|
||||
Point2f Point2f::operator+(const Point2f& other) const {
|
||||
return Point2f { x + other.x, y + other.y };
|
||||
}
|
||||
Point2f Point2f::operator+=(const Point2f& other) const {
|
||||
return Point2f { x + other.x, y + other.y };
|
||||
}
|
||||
Point2f Point2f::operator*(float other) const {
|
||||
return Point2f { x * other, y * other };
|
||||
}
|
||||
Point2f Point2f::operator*(const Point2f& other) const {
|
||||
return Point2f { x * other.x, y * other.y };
|
||||
}
|
||||
Point2f Point2f::operator*(int other) const {
|
||||
return Point2f { x * float(other), y * float(other) };
|
||||
}
|
||||
Point2f Point2f::operator/(float other) const {
|
||||
return Point2f { x / other, y / other };
|
||||
}
|
||||
Point2f Point2f::operator-(const Point2f& other) const {
|
||||
return Point2f { x - other.x, y - other.y };
|
||||
}
|
||||
// Vector2f::Vector2f()
|
||||
// : Vector2f { 0.0f, 0.0f } {
|
||||
// }
|
||||
// Vector2f::Vector2f(float x, float y)
|
||||
// : x { x }, y { y } {
|
||||
// }
|
||||
// Vector2f Vector2f::operator+(const Vector2f& other) const {
|
||||
// return Vector2f { x + other.x, y + other.y };
|
||||
// }
|
||||
// Vector2f Vector2f::operator+=(const Vector2f& other) const {
|
||||
// return Vector2f { x + other.x, y + other.y };
|
||||
// }
|
||||
// Vector2f Vector2f::operator*(float other) const {
|
||||
// return Vector2f { x * other, y * other };
|
||||
// }
|
||||
// Vector2f Vector2f::operator*(const Vector2f& other) const {
|
||||
// return Vector2f { x * other.x, y * other.y };
|
||||
// }
|
||||
// Vector2f Vector2f::operator*(int other) const {
|
||||
// return Vector2f { x * float(other), y * float(other) };
|
||||
// }
|
||||
// Vector2f Vector2f::operator/(float other) const {
|
||||
// return Vector2f { x / other, y / other };
|
||||
// }
|
||||
// Vector2f Vector2f::operator-(const Vector2f& other) const {
|
||||
// return Vector2f { x - other.x, y - other.y };
|
||||
// }
|
||||
|
||||
// Point2f::Point2f(int x, int y)
|
||||
// Vector2f::Vector2f(int x, int y)
|
||||
// : x { (float)x }, y { (float)y } {
|
||||
// }
|
||||
|
||||
Point2f operator/(float right, const Point2f& left) {
|
||||
return Point2f { right / left.x, right / left.y };
|
||||
}
|
||||
Point2f operator*(float right, const Point2f& left) {
|
||||
return Point2f{ right * left.x, right * left.y };
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& os, const Point2f& p) {
|
||||
os << "Point2f( " << p.x << ", " << p.y << " )" << std::endl;
|
||||
return os;
|
||||
}
|
||||
// Vector2f operator/(float right, const Vector2f& left) {
|
||||
// return Vector2f { right / left.x, right / left.y };
|
||||
// }
|
||||
// Vector2f operator*(float right, const Vector2f& left) {
|
||||
// return Vector2f{ right * left.x, right * left.y };
|
||||
// }
|
||||
// std::ostream& operator<<(std::ostream& os, const Vector2f& p) {
|
||||
// os << "Vector2f( " << p.x << ", " << p.y << " )" << std::endl;
|
||||
// return os;
|
||||
// }
|
||||
//-----------------------------------------------------------------
|
||||
// Rectf Constructors
|
||||
//-----------------------------------------------------------------
|
||||
@@ -71,7 +71,7 @@ Rectf::Rectf(float left, float bottom, float width, float height)
|
||||
, width { width }
|
||||
, height { height } {
|
||||
}
|
||||
Rectf::Rectf(Point2f pos, Point2f size): left(pos.x), bottom(pos.y), width(size.x), height(size.y) {}
|
||||
Rectf::Rectf(Vector2f pos, Vector2f size): left(pos.x), bottom(pos.y), width(size.x), height(size.y) {}
|
||||
// Rectf::Rectf(int left, int bottom, int width, int height) : left { (float)left }, bottom { (float)bottom }, width { (float)width }, height { (float)height } {
|
||||
// }
|
||||
|
||||
@@ -97,10 +97,10 @@ Circlef::Circlef()
|
||||
}
|
||||
|
||||
Circlef::Circlef(float centerX, float centerY, float radius)
|
||||
: Circlef { Point2f { centerX, centerY }, radius } {
|
||||
: Circlef { Vector2f { centerX, centerY }, radius } {
|
||||
}
|
||||
|
||||
Circlef::Circlef(const Point2f& center, float radius)
|
||||
Circlef::Circlef(const Vector2f& center, float radius)
|
||||
: center { center }
|
||||
, radius { radius } {
|
||||
}
|
||||
@@ -113,12 +113,12 @@ Ellipsef::Ellipsef()
|
||||
}
|
||||
|
||||
|
||||
Ellipsef::Ellipsef(const Point2f& center, float radiusX, float radiusY)
|
||||
Ellipsef::Ellipsef(const Vector2f& center, float radiusX, float radiusY)
|
||||
: center { center }
|
||||
, radiusX { radiusX }
|
||||
, radiusY { radiusY } {
|
||||
}
|
||||
|
||||
Ellipsef::Ellipsef(float centerX, float centerY, float radiusX, float radiusY)
|
||||
: Ellipsef { Point2f { centerX, centerY }, radiusX, radiusY } {
|
||||
: Ellipsef { Vector2f { centerX, centerY }, radiusX, radiusY } {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Vector2f.h"
|
||||
|
||||
struct Window
|
||||
{
|
||||
explicit Window( const std::string& title = "Title", float width = 320.0f,
|
||||
@@ -12,45 +14,44 @@ struct Window
|
||||
bool isVSyncOn;
|
||||
};
|
||||
|
||||
struct Point2f
|
||||
{
|
||||
Point2f( );
|
||||
explicit Point2f( float x, float y );
|
||||
//Point2f(int x, int y); //Stupid fix for it giving an error
|
||||
|
||||
//operator
|
||||
Point2f operator+( const Point2f& other ) const;
|
||||
Point2f operator+=( const Point2f& other ) const;
|
||||
Point2f operator*( float other ) const;
|
||||
Point2f operator*( int other ) const;
|
||||
Point2f operator*( const Point2f& other ) const;
|
||||
Point2f operator/( float other ) const;
|
||||
Point2f operator-( const Point2f& other ) const;
|
||||
|
||||
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
Point2f operator/(float right, const Point2f& left);
|
||||
Point2f operator*(float right, const Point2f& left);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Point2f& p);
|
||||
// struct Vector2f
|
||||
// {
|
||||
// Vector2f( );
|
||||
// explicit Vector2f( float x, float y );
|
||||
// //Vector2f(int x, int y); //Stupid fix for it giving an error
|
||||
//
|
||||
// //operator
|
||||
// Vector2f operator+( const Vector2f& other ) const;
|
||||
// Vector2f operator+=( const Vector2f& other ) const;
|
||||
// Vector2f operator*( float other ) const;
|
||||
// Vector2f operator*( int other ) const;
|
||||
// Vector2f operator*( const Vector2f& other ) const;
|
||||
// Vector2f operator/( float other ) const;
|
||||
// Vector2f operator-( const Vector2f& other ) const;
|
||||
//
|
||||
//
|
||||
// float x;
|
||||
// float y;
|
||||
// };
|
||||
//
|
||||
// Vector2f operator/(float right, const Vector2f& left);
|
||||
// Vector2f operator*(float right, const Vector2f& left);
|
||||
//
|
||||
// std::ostream& operator<<(std::ostream& os, const Vector2f& p);
|
||||
|
||||
struct Rectf
|
||||
{
|
||||
Rectf( );
|
||||
explicit Rectf( float left, float bottom, float width, float height );
|
||||
Rectf(Point2f pos, Point2f size);
|
||||
//explicit Rectf( int left, int bottom, int width, int height ); //Stupid fix for it giving an error (same as Point2f)
|
||||
Rectf(Vector2f pos, Vector2f size);
|
||||
//explicit Rectf( int left, int bottom, int width, int height ); //Stupid fix for it giving an error (same as Vector2f)
|
||||
|
||||
Point2f BottomLeft() const { return Point2f{ left, bottom }; }
|
||||
Vector2f BottomLeft() const { return Vector2f{ left, bottom }; }
|
||||
|
||||
float left;
|
||||
float bottom;
|
||||
float width;
|
||||
float height;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -68,10 +69,10 @@ struct Color4f
|
||||
struct Circlef
|
||||
{
|
||||
Circlef( );
|
||||
explicit Circlef( const Point2f& center, float radius );
|
||||
explicit Circlef( const Vector2f& center, float radius );
|
||||
explicit Circlef( float centerX, float centerY, float radius );
|
||||
|
||||
Point2f center;
|
||||
Vector2f center;
|
||||
float radius;
|
||||
};
|
||||
|
||||
@@ -79,10 +80,10 @@ struct Circlef
|
||||
struct Ellipsef
|
||||
{
|
||||
Ellipsef( );
|
||||
explicit Ellipsef( const Point2f& center, float radiusX, float radiusY );
|
||||
explicit Ellipsef( const Vector2f& center, float radiusX, float radiusY );
|
||||
explicit Ellipsef( float centerX, float centerY, float radiusX, float radiusY );
|
||||
|
||||
Point2f center;
|
||||
Vector2f center;
|
||||
float radiusX;
|
||||
float radiusY;
|
||||
};
|
||||
|
||||
132
Engine/utils.cpp
132
Engine/utils.cpp
@@ -24,11 +24,11 @@ void utils::DrawPoint(float x, float y, float pointSize) {
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void utils::DrawPoint(const Point2f& p, float pointSize) {
|
||||
void utils::DrawPoint(const Vector2f& p, float pointSize) {
|
||||
DrawPoint(p.x, p.y, pointSize);
|
||||
}
|
||||
|
||||
void utils::DrawPoints(Point2f* pVertices, int nrVertices, float pointSize) {
|
||||
void utils::DrawPoints(Vector2f* pVertices, int nrVertices, float pointSize) {
|
||||
glPointSize(pointSize);
|
||||
glBegin(GL_POINTS);
|
||||
{
|
||||
@@ -49,11 +49,11 @@ void utils::DrawLine(float x1, float y1, float x2, float y2, float lineWidth) {
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void utils::DrawLine(const Point2f& p1, const Point2f& p2, float lineWidth) {
|
||||
void utils::DrawLine(const Vector2f& p1, const Vector2f& p2, float lineWidth) {
|
||||
DrawLine(p1.x, p1.y, p2.x, p2.y, lineWidth);
|
||||
}
|
||||
|
||||
void utils::DrawTriangle(const Point2f& p1, const Point2f& p2, const Point2f& p3, float lineWidth) {
|
||||
void utils::DrawTriangle(const Vector2f& p1, const Vector2f& p2, const Vector2f& p3, float lineWidth) {
|
||||
glLineWidth(lineWidth);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
{
|
||||
@@ -64,7 +64,7 @@ void utils::DrawTriangle(const Point2f& p1, const Point2f& p2, const Point2f& p3
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void utils::FillTriangle(const Point2f& p1, const Point2f& p2, const Point2f& p3) {
|
||||
void utils::FillTriangle(const Vector2f& p1, const Vector2f& p2, const Vector2f& p3) {
|
||||
glBegin(GL_TRIANGLES);
|
||||
{
|
||||
glVertex2f(p1.x, p1.y);
|
||||
@@ -89,7 +89,7 @@ void utils::DrawRect(float left, float bottom, float width, float height, float
|
||||
}
|
||||
}
|
||||
|
||||
void utils::DrawRect(const Point2f& bottomLeft, float width, float height, float lineWidth) {
|
||||
void utils::DrawRect(const Vector2f& bottomLeft, float width, float height, float lineWidth) {
|
||||
DrawRect(bottomLeft.x, bottomLeft.y, width, height, lineWidth);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ void utils::FillRect(float left, float bottom, float width, float height) {
|
||||
}
|
||||
}
|
||||
|
||||
void utils::FillRect(const Point2f& bottomLeft, float width, float height) {
|
||||
void utils::FillRect(const Vector2f& bottomLeft, float width, float height) {
|
||||
FillRect(bottomLeft.x, bottomLeft.y, width, height);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void utils::DrawEllipse(float centerX, float centerY, float radX, float radY, fl
|
||||
}
|
||||
}
|
||||
|
||||
void utils::DrawEllipse(const Point2f& center, float radX, float radY, float lineWidth) {
|
||||
void utils::DrawEllipse(const Vector2f& center, float radX, float radY, float lineWidth) {
|
||||
DrawEllipse(center.x, center.y, radX, radY, lineWidth);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void utils::FillEllipse(const Ellipsef& ellipse) {
|
||||
FillEllipse(ellipse.center.x, ellipse.center.y, ellipse.radiusX, ellipse.radiusY);
|
||||
}
|
||||
|
||||
void utils::FillEllipse(const Point2f& center, float radX, float radY) {
|
||||
void utils::FillEllipse(const Vector2f& center, float radX, float radY) {
|
||||
FillEllipse(center.x, center.y, radX, radY);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ void utils::DrawArc(float centerX, float centerY, float radX, float radY, float
|
||||
|
||||
}
|
||||
|
||||
void utils::DrawArc(const Point2f& center, float radX, float radY, float fromAngle, float tillAngle, float lineWidth) {
|
||||
void utils::DrawArc(const Vector2f& center, float radX, float radY, float fromAngle, float tillAngle, float lineWidth) {
|
||||
DrawArc(center.x, center.y, radX, radY, fromAngle, tillAngle, lineWidth);
|
||||
}
|
||||
|
||||
@@ -206,15 +206,15 @@ void utils::FillArc(float centerX, float centerY, float radX, float radY, float
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void utils::FillArc(const Point2f& center, float radX, float radY, float fromAngle, float tillAngle) {
|
||||
void utils::FillArc(const Vector2f& center, float radX, float radY, float fromAngle, float tillAngle) {
|
||||
FillArc(center.x, center.y, radX, radY, fromAngle, tillAngle);
|
||||
}
|
||||
|
||||
void utils::DrawPolygon(const std::vector<Point2f>& vertices, bool closed, float lineWidth) {
|
||||
void utils::DrawPolygon(const std::vector<Vector2f>& vertices, bool closed, float lineWidth) {
|
||||
DrawPolygon(vertices.data(), vertices.size(), closed, lineWidth);
|
||||
}
|
||||
|
||||
void utils::DrawPolygon(const Point2f* pVertices, size_t nrVertices, bool closed, float lineWidth) {
|
||||
void utils::DrawPolygon(const Vector2f* pVertices, size_t nrVertices, bool closed, float lineWidth) {
|
||||
glLineWidth(lineWidth);
|
||||
closed ? glBegin(GL_LINE_LOOP) : glBegin(GL_LINE_STRIP);
|
||||
{
|
||||
@@ -225,11 +225,11 @@ void utils::DrawPolygon(const Point2f* pVertices, size_t nrVertices, bool closed
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void utils::FillPolygon(const std::vector<Point2f>& vertices) {
|
||||
void utils::FillPolygon(const std::vector<Vector2f>& vertices) {
|
||||
FillPolygon(vertices.data(), vertices.size());
|
||||
}
|
||||
|
||||
void utils::FillPolygon(const Point2f* pVertices, size_t nrVertices) {
|
||||
void utils::FillPolygon(const Vector2f* pVertices, size_t nrVertices) {
|
||||
glBegin(GL_POLYGON);
|
||||
{
|
||||
for (size_t idx { 0 }; idx < nrVertices; ++idx) {
|
||||
@@ -245,34 +245,34 @@ float utils::GetDistance(float x1, float y1, float x2, float y2) {
|
||||
return ( sqrtf(( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 )) );
|
||||
}
|
||||
|
||||
float utils::GetDistance(const Point2f& p1, const Point2f& p2) {
|
||||
float utils::GetDistance(const Vector2f& p1, const Vector2f& p2) {
|
||||
return GetDistance(p1.x, p1.y, p2.x, p2.y);
|
||||
}
|
||||
|
||||
bool utils::IsPointInRect(const Point2f& p, const Rectf& r) {
|
||||
bool utils::IsPointInRect(const Vector2f& p, const Rectf& r) {
|
||||
return ( p.x >= r.left &&
|
||||
p.x <= r.left + r.width &&
|
||||
p.y >= r.bottom &&
|
||||
p.y <= r.bottom + r.height );
|
||||
}
|
||||
|
||||
bool utils::IsPointInCircle(const Point2f& p, const Circlef& c) {
|
||||
bool utils::IsPointInCircle(const Vector2f& p, const Circlef& c) {
|
||||
float squaredDist { ( p.x - c.center.x ) * ( p.x - c.center.x ) + ( p.y - c.center.y ) * ( p.y - c.center.y ) };
|
||||
float squaredRadius { c.radius * c.radius };
|
||||
return ( squaredRadius >= squaredDist );
|
||||
}
|
||||
|
||||
bool utils::IsOverlapping(const Point2f& a, const Point2f& b, const Rectf& r) {
|
||||
bool utils::IsOverlapping(const Vector2f& a, const Vector2f& b, const Rectf& r) {
|
||||
// if one of the line segment end points is in the rect
|
||||
if (utils::IsPointInRect(a, r) || utils::IsPointInRect(b, r)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
HitInfo hitInfo {};
|
||||
Point2f vertices[] { Point2f { r.left, r.bottom },
|
||||
Point2f { r.left + r.width, r.bottom },
|
||||
Point2f { r.left + r.width, r.bottom + r.height },
|
||||
Point2f { r.left, r.bottom + r.height } };
|
||||
Vector2f vertices[] { Vector2f { r.left, r.bottom },
|
||||
Vector2f { r.left + r.width, r.bottom },
|
||||
Vector2f { r.left + r.width, r.bottom + r.height },
|
||||
Vector2f { r.left, r.bottom + r.height } };
|
||||
|
||||
return Raycast(vertices, 4, a, b, hitInfo);
|
||||
}
|
||||
@@ -297,16 +297,16 @@ bool utils::IsOverlapping(const Rectf& r, const Circlef& c) {
|
||||
return true;
|
||||
}
|
||||
// Check line segments
|
||||
if (utils::DistPointLineSegment(c.center, Point2f { r.left, r.bottom }, Point2f { r.left, r.bottom + r.height }) <= c.radius) {
|
||||
if (utils::DistPointLineSegment(c.center, Vector2f { r.left, r.bottom }, Vector2f { r.left, r.bottom + r.height }) <= c.radius) {
|
||||
return true;
|
||||
}
|
||||
if (utils::DistPointLineSegment(c.center, Point2f { r.left, r.bottom }, Point2f { r.left + r.width, r.bottom }) <= c.radius) {
|
||||
if (utils::DistPointLineSegment(c.center, Vector2f { r.left, r.bottom }, Vector2f { r.left + r.width, r.bottom }) <= c.radius) {
|
||||
return true;
|
||||
}
|
||||
if (utils::DistPointLineSegment(c.center, Point2f { r.left + r.width, r.bottom + r.height }, Point2f { r.left, r.bottom + r.height }) <= c.radius) {
|
||||
if (utils::DistPointLineSegment(c.center, Vector2f { r.left + r.width, r.bottom + r.height }, Vector2f { r.left, r.bottom + r.height }) <= c.radius) {
|
||||
return true;
|
||||
}
|
||||
if (utils::DistPointLineSegment(c.center, Point2f { r.left + r.width, r.bottom + r.height }, Point2f { r.left + r.width, r.bottom }) <= c.radius) {
|
||||
if (utils::DistPointLineSegment(c.center, Vector2f { r.left + r.width, r.bottom + r.height }, Vector2f { r.left + r.width, r.bottom }) <= c.radius) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -322,15 +322,15 @@ bool utils::IsOverlapping(const Circlef& c1, const Circlef& c2) {
|
||||
return ( squaredDistance < squaredTouchingDistance );
|
||||
}
|
||||
|
||||
bool utils::IsOverlapping(const Point2f& a, const Point2f& b, const Circlef& c) {
|
||||
bool utils::IsOverlapping(const Vector2f& a, const Vector2f& b, const Circlef& c) {
|
||||
return utils::DistPointLineSegment(c.center, a, b) <= c.radius;
|
||||
}
|
||||
|
||||
bool utils::IsOverlapping(const std::vector<Point2f>& vertices, const Circlef& c) {
|
||||
bool utils::IsOverlapping(const std::vector<Vector2f>& vertices, const Circlef& c) {
|
||||
return IsOverlapping(vertices.data(), vertices.size(), c);
|
||||
}
|
||||
|
||||
bool utils::IsOverlapping(const Point2f* vertices, size_t nrVertices, const Circlef& c) {
|
||||
bool utils::IsOverlapping(const Vector2f* vertices, size_t nrVertices, const Circlef& c) {
|
||||
// Verify whether one of vertices is in circle
|
||||
for (size_t i { 0 }; i < nrVertices; ++i) {
|
||||
if (IsPointInCircle(vertices[i], c)) {
|
||||
@@ -352,11 +352,11 @@ bool utils::IsOverlapping(const Point2f* vertices, size_t nrVertices, const Circ
|
||||
return false;
|
||||
}
|
||||
|
||||
bool utils::IsPointInPolygon(const Point2f& p, const std::vector<Point2f>& vertices) {
|
||||
bool utils::IsPointInPolygon(const Vector2f& p, const std::vector<Vector2f>& vertices) {
|
||||
return IsPointInPolygon(p, vertices.data(), vertices.size());
|
||||
}
|
||||
|
||||
bool utils::IsPointInPolygon(const Point2f& p, const Point2f* vertices, size_t nrVertices) {
|
||||
bool utils::IsPointInPolygon(const Vector2f& p, const Vector2f* vertices, size_t nrVertices) {
|
||||
if (nrVertices < 2) {
|
||||
return false;
|
||||
}
|
||||
@@ -387,7 +387,7 @@ bool utils::IsPointInPolygon(const Point2f& p, const Point2f* vertices, size_t n
|
||||
// and count how often it hits any side of the polygon.
|
||||
// If the number of hits is even, it's outside of the polygon, if it's odd, it's inside.
|
||||
int numberOfIntersectionPoints { 0 };
|
||||
Point2f p2 { xMax + 10.0f, p.y }; // Horizontal line from point to point outside polygon (p2)
|
||||
Vector2f p2 { xMax + 10.0f, p.y }; // Horizontal line from point to point outside polygon (p2)
|
||||
|
||||
// Count the number of intersection points
|
||||
float lambda1 {}, lambda2 {};
|
||||
@@ -406,7 +406,7 @@ bool utils::IsPointInPolygon(const Point2f& p, const Point2f* vertices, size_t n
|
||||
}
|
||||
}
|
||||
|
||||
bool utils::IntersectLineSegments(const Point2f& p1, const Point2f& p2, const Point2f& q1, const Point2f& q2, float& outLambda1, float& outLambda2, float epsilon) {
|
||||
bool utils::IntersectLineSegments(const Vector2f& p1, const Vector2f& p2, const Vector2f& q1, const Vector2f& q2, float& outLambda1, float& outLambda2, float epsilon) {
|
||||
bool intersecting { false };
|
||||
|
||||
Vector2f p1p2 { p1, p2 };
|
||||
@@ -451,11 +451,11 @@ bool utils::IntersectLineSegments(const Point2f& p1, const Point2f& p2, const Po
|
||||
return intersecting;
|
||||
}
|
||||
|
||||
bool utils::Raycast(const std::vector<Point2f>& vertices, const Point2f& rayP1, const Point2f& rayP2, HitInfo& hitInfo) {
|
||||
bool utils::Raycast(const std::vector<Vector2f>& vertices, const Vector2f& rayP1, const Vector2f& rayP2, HitInfo& hitInfo) {
|
||||
return Raycast(vertices.data(), vertices.size(), rayP1, rayP2, hitInfo);
|
||||
}
|
||||
|
||||
bool utils::Raycast(const Point2f* vertices, const size_t nrVertices, const Point2f& rayP1, const Point2f& rayP2, HitInfo& hitInfo) {
|
||||
bool utils::Raycast(const Vector2f* vertices, const size_t nrVertices, const Vector2f& rayP1, const Vector2f& rayP2, HitInfo& hitInfo) {
|
||||
if (nrVertices == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -473,8 +473,8 @@ bool utils::Raycast(const Point2f* vertices, const size_t nrVertices, const Poin
|
||||
for (size_t idx { 0 }; idx <= nrVertices; ++idx) {
|
||||
// Consider line segment between 2 consecutive vertices
|
||||
// (modulo to allow closed polygon, last - first vertice)
|
||||
Point2f q1 = vertices[( idx + 0 ) % nrVertices];
|
||||
Point2f q2 = vertices[( idx + 1 ) % nrVertices];
|
||||
Vector2f q1 = vertices[( idx + 0 ) % nrVertices];
|
||||
Vector2f q2 = vertices[( idx + 1 ) % nrVertices];
|
||||
|
||||
// r2: minimal AABB rect enclosing the 2 vertices
|
||||
r2.left = std::min(q1.x, q2.x);
|
||||
@@ -489,7 +489,7 @@ bool utils::Raycast(const Point2f* vertices, const size_t nrVertices, const Poin
|
||||
if (lambda1 > 0 && lambda1 <= 1 && lambda2 > 0 && lambda2 <= 1) {
|
||||
HitInfo linesHitInfo {};
|
||||
linesHitInfo.lambda = lambda1;
|
||||
linesHitInfo.intersectPoint = Point2f { rayP1.x + ( ( rayP2.x - rayP1.x ) * lambda1 ), rayP1.y + ( ( rayP2.y - rayP1.y ) * lambda1 ) };
|
||||
linesHitInfo.intersectPoint = Vector2f { rayP1.x + ( ( rayP2.x - rayP1.x ) * lambda1 ), rayP1.y + ( ( rayP2.y - rayP1.y ) * lambda1 ) };
|
||||
linesHitInfo.normal = Vector2f { q2.x - q1.x, q2.y - q2.y }.Orthogonal().Normalized();
|
||||
hits.push_back(linesHitInfo);
|
||||
}
|
||||
@@ -513,7 +513,7 @@ bool utils::Raycast(const Point2f* vertices, const size_t nrVertices, const Poin
|
||||
return true;
|
||||
}
|
||||
|
||||
bool utils::IsPointOnLineSegment(const Point2f& p, const Point2f& a, const Point2f& b) {
|
||||
bool utils::IsPointOnLineSegment(const Vector2f& p, const Vector2f& a, const Vector2f& b) {
|
||||
Vector2f ap { a, p }, bp { b, p };
|
||||
// If not on same line, return false
|
||||
if (abs(ap.CrossProduct(bp)) > 0.001f) {
|
||||
@@ -528,7 +528,7 @@ bool utils::IsPointOnLineSegment(const Point2f& p, const Point2f& a, const Point
|
||||
return true;
|
||||
}
|
||||
|
||||
float utils::DistPointLineSegment(const Point2f& p, const Point2f& a, const Point2f& b) {
|
||||
float utils::DistPointLineSegment(const Vector2f& p, const Vector2f& a, const Vector2f& b) {
|
||||
Vector2f ab { a, b };
|
||||
Vector2f ap { a, p };
|
||||
Vector2f abNorm { ab.Normalized() };
|
||||
@@ -551,7 +551,7 @@ float utils::DistPointLineSegment(const Point2f& p, const Point2f& a, const Poin
|
||||
return Vector2f { p.x - intersection.x, p.y - intersection.y }.Length();
|
||||
}
|
||||
|
||||
bool utils::IntersectRectLine(const Rectf& r, const Point2f& p1, const Point2f& p2, float& intersectMin, float& intersectMax) {
|
||||
bool utils::IntersectRectLine(const Rectf& r, const Vector2f& p1, const Vector2f& p2, float& intersectMin, float& intersectMax) {
|
||||
// Parameters
|
||||
// input:
|
||||
// r: axis aligned bounding box, start and end points of line segment.
|
||||
@@ -566,8 +566,8 @@ bool utils::IntersectRectLine(const Rectf& r, const Point2f& p1, const Point2f&
|
||||
//float max{};
|
||||
//if (utils::IntersectRectLine(rect, p1, p2, min, max))
|
||||
//{
|
||||
// Point2f intersectP1{ p1 + (Vector2f(p2) - Vector2f(p1)) * min };
|
||||
// Point2f intersectP2{ p1 + (Vector2f(p2) - Vector2f(p1)) * max };
|
||||
// Vector2f intersectP1{ p1 + (Vector2f(p2) - Vector2f(p1)) * min };
|
||||
// Vector2f intersectP2{ p1 + (Vector2f(p2) - Vector2f(p1)) * max };
|
||||
//}
|
||||
|
||||
// 4 floats to convert rect space to line space
|
||||
@@ -592,14 +592,14 @@ bool utils::IsRectInRect(const Rectf& r1, const Rectf& r2) {
|
||||
// the origin of both rectangles is in bottom left
|
||||
return ( r1.left < r2.left + r2.width && r1.left + r1.width > r2.left && r1.bottom < r2.bottom + r2.height && r1.bottom + r1.height > r2.bottom );
|
||||
}
|
||||
bool utils::RayVsRect(const Point2f& rayOrigin, const Point2f& rayDir, const Rectf& target,
|
||||
Point2f& contactPoint, Point2f& contactNormal, float& t_hit_near) {
|
||||
bool utils::RayVsRect(const Vector2f& rayOrigin, const Vector2f& rayDir, const Rectf& target,
|
||||
Vector2f& contactPoint, Vector2f& contactNormal, float& t_hit_near) {
|
||||
|
||||
// Point2f t_near = Point2f{(target.BottomLeft() - rayOrigin).x / rayDir.x, (target.BottomLeft() - rayOrigin).y / rayDir.y};
|
||||
// Point2f t_far = Point2f{(target.BottomLeft() + Point2f{target.width, target.height} - rayOrigin).x / rayDir.x, (target.BottomLeft() + Point2f{target.width, target.height} - rayOrigin).y / rayDir.y};
|
||||
// Vector2f t_near = Vector2f{(target.BottomLeft() - rayOrigin).x / rayDir.x, (target.BottomLeft() - rayOrigin).y / rayDir.y};
|
||||
// Vector2f t_far = Vector2f{(target.BottomLeft() + Vector2f{target.width, target.height} - rayOrigin).x / rayDir.x, (target.BottomLeft() + Vector2f{target.width, target.height} - rayOrigin).y / rayDir.y};
|
||||
|
||||
Point2f t_near {};
|
||||
Point2f t_far {};
|
||||
Vector2f t_near {};
|
||||
Vector2f t_far {};
|
||||
|
||||
if (std::isnan(t_far.y) || std::isnan(t_far.x))
|
||||
return false;
|
||||
@@ -624,24 +624,24 @@ bool utils::RayVsRect(const Point2f& rayOrigin, const Point2f& rayDir, const Rec
|
||||
|
||||
if (t_near.x > t_near.y) {
|
||||
if (rayDir.x < 0) {
|
||||
contactNormal = Point2f { 1, 0 };
|
||||
contactNormal = Vector2f { 1, 0 };
|
||||
}
|
||||
else {
|
||||
contactNormal = Point2f { -1, 0 };
|
||||
contactNormal = Vector2f { -1, 0 };
|
||||
}
|
||||
}
|
||||
else if (t_near.x < t_near.y) {
|
||||
if (rayDir.y < 0) {
|
||||
contactNormal = Point2f { 0, 1 };
|
||||
contactNormal = Vector2f { 0, 1 };
|
||||
}
|
||||
else {
|
||||
contactNormal = Point2f { 0, -1 };
|
||||
contactNormal = Vector2f { 0, -1 };
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool utils::DynamicRectVsRect(const MovingRectf& in, const Rectf& target, Point2f& contactPoint, Point2f& contactNormal, float& contactTime, float dt) {
|
||||
bool utils::DynamicRectVsRect(const MovingRectf& in, const Rectf& target, Vector2f& contactPoint, Vector2f& contactNormal, float& contactTime, float dt) {
|
||||
if (in.velocity.x == 0 && in.velocity.y == 0)
|
||||
return false;
|
||||
|
||||
@@ -652,14 +652,14 @@ bool utils::DynamicRectVsRect(const MovingRectf& in, const Rectf& target, Point2
|
||||
expanded_target.width = target.width + in.width;
|
||||
expanded_target.height = target.height + in.height;
|
||||
|
||||
if (RayVsRect(Point2f { in.bottomLeft.x + in.width / 2, in.bottomLeft.y + in.height / 2 }, in.velocity * dt, expanded_target, contactPoint, contactNormal, contactTime)) {
|
||||
if (RayVsRect(Vector2f { in.bottomLeft.x + in.width / 2, in.bottomLeft.y + in.height / 2 }, in.velocity * dt, expanded_target, contactPoint, contactNormal, contactTime)) {
|
||||
if (contactTime <= 1.0f && contactTime >= 0.0f) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
float utils::DotProduct(const Point2f& a, const Point2f& b) {
|
||||
float utils::DotProduct(const Vector2f& a, const Vector2f& b) {
|
||||
return a.x * b.x + a.y * b.y;
|
||||
}
|
||||
#pragma endregion CollisionFunctionality
|
||||
@@ -667,6 +667,16 @@ float utils::DotProduct(const Point2f& a, const Point2f& b) {
|
||||
int utils::randRange(int min, int max) {
|
||||
return min + rand() % ( ( max + 1 ) - min );
|
||||
}
|
||||
float utils::lerp(float a, float b, float t) {
|
||||
return a + t * ( b - a );
|
||||
}
|
||||
Vector2f utils::lerp(const Vector2f& a, const Vector2f& b, float t) {
|
||||
return Vector2f { lerp(a.x, b.x, t), lerp(a.y, b.y, t) };
|
||||
}
|
||||
float utils::map(float value, float start1, float stop1, float start2, float stop2) {
|
||||
float newVal = (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
|
||||
return newVal;
|
||||
}
|
||||
bool utils::isKeyDown(int keycode) {
|
||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||
if (pStates != nullptr) {
|
||||
@@ -699,11 +709,11 @@ bool utils::isKeyUp(int keycode) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Point2f utils::GetMousePos() {
|
||||
Vector2f utils::GetMousePos() {
|
||||
int x, y;
|
||||
SDL_GetMouseState(&x, &y);
|
||||
//TODO: make the screen size a global or something
|
||||
return Point2f { float(x), float(500.f - y) };
|
||||
return Vector2f { float(x), float(500.f - y) };
|
||||
}
|
||||
bool utils::IsMouseButtonDown(int button) {
|
||||
const Uint32 pStates = SDL_GetMouseState(nullptr, nullptr);
|
||||
@@ -712,8 +722,8 @@ bool utils::IsMouseButtonDown(int button) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static Point2f ViewportSize{ 900.f, 500.f }; //TODO: somehow move this (Ask teacher)
|
||||
Point2f utils::GetViewport() {
|
||||
static Vector2f ViewportSize{ 900.f, 500.f }; //TODO: somehow move this (Ask teacher)
|
||||
Vector2f utils::GetViewport() {
|
||||
return ViewportSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace utils
|
||||
|
||||
struct MovingRectf
|
||||
{
|
||||
Point2f bottomLeft;
|
||||
Vector2f bottomLeft;
|
||||
float width;
|
||||
float height;
|
||||
|
||||
Point2f velocity;
|
||||
Vector2f velocity;
|
||||
};
|
||||
|
||||
#pragma region OpenGLDrawFunctionality
|
||||
@@ -24,86 +24,91 @@ namespace utils
|
||||
void ClearBackground( const Color4f& color );
|
||||
|
||||
void DrawPoint( float x, float y, float pointSize = 1.0f );
|
||||
void DrawPoint( const Point2f& p, float pointSize = 1.0f );
|
||||
void DrawPoints( Point2f *pVertices, int nrVertices, float pointSize = 1.0f );
|
||||
void DrawPoint( const Vector2f& p, float pointSize = 1.0f );
|
||||
void DrawPoints( Vector2f *pVertices, int nrVertices, float pointSize = 1.0f );
|
||||
|
||||
void DrawLine( float x1, float y1, float x2, float y2, float lineWidth = 1.0f );
|
||||
void DrawLine( const Point2f& p1, const Point2f& p2, float lineWidth = 1.0f );
|
||||
void DrawLine( const Vector2f& p1, const Vector2f& p2, float lineWidth = 1.0f );
|
||||
|
||||
void DrawTriangle(const Point2f& p1, const Point2f& p2, const Point2f& p3, float lineWidth = 1);
|
||||
void FillTriangle(const Point2f& p1, const Point2f& p2, const Point2f& p3);
|
||||
void DrawTriangle(const Vector2f& p1, const Vector2f& p2, const Vector2f& p3, float lineWidth = 1);
|
||||
void FillTriangle(const Vector2f& p1, const Vector2f& p2, const Vector2f& p3);
|
||||
|
||||
void DrawRect(float left, float bottom, float width, float height, float lineWidth = 1.0f);
|
||||
void DrawRect(const Point2f& bottomLeft, float width, float height, float lineWidth = 1.0f);
|
||||
void DrawRect(const Vector2f& bottomLeft, float width, float height, float lineWidth = 1.0f);
|
||||
void DrawRect(const Rectf& rect, float lineWidth = 1.0f);
|
||||
void FillRect(float left, float bottom, float width, float height);
|
||||
void FillRect(const Point2f& bottomLeft, float width, float height);
|
||||
void FillRect(const Vector2f& bottomLeft, float width, float height);
|
||||
void FillRect(const Rectf& rect);
|
||||
|
||||
void DrawEllipse(float centerX, float centerY, float radX, float radY, float lineWidth = 1.0f);
|
||||
void DrawEllipse(const Point2f& center, float radX, float radY, float lineWidth = 1.0f);
|
||||
void DrawEllipse(const Vector2f& center, float radX, float radY, float lineWidth = 1.0f);
|
||||
void DrawEllipse(const Ellipsef& ellipse , float lineWidth = 1.0f );
|
||||
void FillEllipse( float centerX, float centerY, float radX, float radY );
|
||||
void FillEllipse(const Ellipsef& ellipse );
|
||||
void FillEllipse(const Point2f& center, float radX, float radY);
|
||||
void FillEllipse(const Vector2f& center, float radX, float radY);
|
||||
|
||||
// Draws an arc. The angle parameters are in radians, not in degrees.
|
||||
void DrawArc(float centerX, float centerY, float radX, float radY, float fromAngle, float tillAngle, float lineWidth = 1.0f);
|
||||
// Draws an arc. The angle parameters are in radians, not in degrees.
|
||||
void DrawArc(const Point2f& center, float radX, float radY, float fromAngle, float tillAngle, float lineWidth = 1.0f);
|
||||
void DrawArc(const Vector2f& center, float radX, float radY, float fromAngle, float tillAngle, float lineWidth = 1.0f);
|
||||
// Fills an arc. The angle parameters are in radians, not in degrees.
|
||||
void FillArc(float centerX, float centerY, float radX, float radY, float fromAngle, float tillAngle);
|
||||
// Fills an arc. The angle parameters are in radians, not in degrees.
|
||||
void FillArc(const Point2f& center, float radX, float radY, float fromAngle, float tillAngle);
|
||||
void FillArc(const Vector2f& center, float radX, float radY, float fromAngle, float tillAngle);
|
||||
|
||||
void DrawPolygon( const std::vector<Point2f>& vertices, bool closed = true, float lineWidth = 1.0f );
|
||||
void DrawPolygon( const Point2f* pVertices, size_t nrVertices, bool closed = true, float lineWidth = 1.0f );
|
||||
void FillPolygon( const std::vector<Point2f>& vertices);
|
||||
void FillPolygon( const Point2f* pVertices, size_t nrVertices);
|
||||
void DrawPolygon( const std::vector<Vector2f>& vertices, bool closed = true, float lineWidth = 1.0f );
|
||||
void DrawPolygon( const Vector2f* pVertices, size_t nrVertices, bool closed = true, float lineWidth = 1.0f );
|
||||
void FillPolygon( const std::vector<Vector2f>& vertices);
|
||||
void FillPolygon( const Vector2f* pVertices, size_t nrVertices);
|
||||
#pragma endregion OpenGLDrawFunctionality
|
||||
|
||||
#pragma region CollisionFunctionality
|
||||
struct HitInfo
|
||||
{
|
||||
float lambda;
|
||||
Point2f intersectPoint;
|
||||
Vector2f intersectPoint;
|
||||
Vector2f normal;
|
||||
};
|
||||
|
||||
float GetDistance(float x1, float y1, float x2, float y2);
|
||||
float GetDistance(const Point2f& p1, const Point2f& p2);
|
||||
float GetDistance(const Vector2f& p1, const Vector2f& p2);
|
||||
|
||||
bool IsPointInRect(const Point2f& p, const Rectf& r);
|
||||
bool IsPointInCircle(const Point2f& p, const Circlef& c);
|
||||
bool IsPointInPolygon( const Point2f& p, const std::vector<Point2f>& vertices );
|
||||
bool IsPointInPolygon( const Point2f& p, const Point2f* vertices, size_t nrVertices );
|
||||
bool IsPointInRect(const Vector2f& p, const Rectf& r);
|
||||
bool IsPointInCircle(const Vector2f& p, const Circlef& c);
|
||||
bool IsPointInPolygon( const Vector2f& p, const std::vector<Vector2f>& vertices );
|
||||
bool IsPointInPolygon( const Vector2f& p, const Vector2f* vertices, size_t nrVertices );
|
||||
|
||||
bool IsOverlapping( const Point2f& a, const Point2f& b, const Circlef& c );
|
||||
bool IsOverlapping( const Point2f& a, const Point2f& b, const Rectf& r );
|
||||
bool IsOverlapping( const Vector2f& a, const Vector2f& b, const Circlef& c );
|
||||
bool IsOverlapping( const Vector2f& a, const Vector2f& b, const Rectf& r );
|
||||
|
||||
bool IsOverlapping(const Rectf & r1, const Rectf & r2);
|
||||
bool IsOverlapping( const Rectf& r, const Circlef& c );
|
||||
bool IsOverlapping( const Circlef& c1, const Circlef& c2 );
|
||||
bool IsOverlapping( const std::vector<Point2f>& vertices, const Circlef& c );
|
||||
bool IsOverlapping( const Point2f* vertices, size_t nrVertices, const Circlef& c );
|
||||
bool IsOverlapping( const std::vector<Vector2f>& vertices, const Circlef& c );
|
||||
bool IsOverlapping( const Vector2f* vertices, size_t nrVertices, const Circlef& c );
|
||||
|
||||
bool Raycast( const Point2f* vertices, const size_t nrVertices, const Point2f& rayP1, const Point2f& rayP2, HitInfo& hitInfo );
|
||||
bool Raycast( const std::vector<Point2f>& vertices, const Point2f& rayP1, const Point2f& rayP2, HitInfo& hitInfo );
|
||||
bool Raycast( const Vector2f* vertices, const size_t nrVertices, const Vector2f& rayP1, const Vector2f& rayP2, HitInfo& hitInfo );
|
||||
bool Raycast( const std::vector<Vector2f>& vertices, const Vector2f& rayP1, const Vector2f& rayP2, HitInfo& hitInfo );
|
||||
|
||||
bool IntersectLineSegments(const Point2f& p1, const Point2f& p2, const Point2f& q1, const Point2f& q2, float& outLambda1, float& outLambda2, float epsilon = 1e-6);
|
||||
float DistPointLineSegment(const Point2f& p, const Point2f& a, const Point2f& b);
|
||||
bool IsPointOnLineSegment(const Point2f& p, const Point2f& a, const Point2f& b);
|
||||
bool IntersectRectLine(const Rectf& r, const Point2f& p1, const Point2f& p2, float& intersectMin, float& intersectMax);
|
||||
bool IntersectLineSegments(const Vector2f& p1, const Vector2f& p2, const Vector2f& q1, const Vector2f& q2, float& outLambda1, float& outLambda2, float epsilon = 1e-6);
|
||||
float DistPointLineSegment(const Vector2f& p, const Vector2f& a, const Vector2f& b);
|
||||
bool IsPointOnLineSegment(const Vector2f& p, const Vector2f& a, const Vector2f& b);
|
||||
bool IntersectRectLine(const Rectf& r, const Vector2f& p1, const Vector2f& p2, float& intersectMin, float& intersectMax);
|
||||
bool IsRectInRect(const Rectf& r1, const Rectf& r2);
|
||||
|
||||
bool RayVsRect(const Point2f& rayOrigin, const Point2f& rayDir, const Rectf& target,
|
||||
Point2f& contactPoint, Point2f& contactNormal, float& contactTime);
|
||||
bool RayVsRect(const Vector2f& rayOrigin, const Vector2f& rayDir, const Rectf& target,
|
||||
Vector2f& contactPoint, Vector2f& contactNormal, float& contactTime);
|
||||
|
||||
bool DynamicRectVsRect(const MovingRectf& in, const Rectf& target, Point2f& contactPoint, Point2f& contactNormal, float& contactTime, float dt);
|
||||
bool DynamicRectVsRect(const MovingRectf& in, const Rectf& target, Vector2f& contactPoint, Vector2f& contactNormal, float& contactTime, float dt);
|
||||
|
||||
float DotProduct(const Point2f& a, const Point2f& b);
|
||||
float DotProduct(const Vector2f& a, const Vector2f& b);
|
||||
|
||||
int randRange(int min, int max);
|
||||
|
||||
float lerp(float a, float 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);
|
||||
#pragma endregion CollisionFunctionality
|
||||
|
||||
bool isKeyDown(SDL_Keycode keycode);
|
||||
@@ -111,11 +116,11 @@ namespace utils
|
||||
bool isMouseDown(int button);
|
||||
bool isKeyUp(int keycode);
|
||||
|
||||
Point2f GetMousePos();
|
||||
Vector2f GetMousePos();
|
||||
bool IsMouseButtonDown(int button);
|
||||
|
||||
|
||||
Point2f GetViewport();
|
||||
Vector2f GetViewport();
|
||||
|
||||
|
||||
}
|
||||
@@ -19,11 +19,11 @@ void Animation::Update(float elapsedSec) {
|
||||
}
|
||||
}
|
||||
}
|
||||
void Animation::Draw(const Point2f& pos) const {
|
||||
void Animation::Draw(const Vector2f& pos) const {
|
||||
Draw(pos, Rectf{ pos.x, pos.y, m_SrcRect.width, m_SrcRect.height });
|
||||
}
|
||||
|
||||
void Animation::Draw(const Point2f& pos, const Rectf& dst) const {
|
||||
void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
|
||||
Rectf src = m_SrcRect;
|
||||
src.left += m_CurrentFrame * src.width;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ public:
|
||||
~Animation();
|
||||
|
||||
void Update(float elapsedSec);
|
||||
void Draw(const Point2f& pos) const;
|
||||
void Draw(const Point2f& pos, const Rectf& dst) const;
|
||||
void Draw(const Vector2f& pos) const;
|
||||
void Draw(const Vector2f& pos, const Rectf& dst) const;
|
||||
|
||||
void SetPlaying(bool isPlaying) {
|
||||
m_isPlaying = isPlaying;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Camera::Camera() : m_Position { 0, 0 }, m_Scale { 1.0f } {
|
||||
}
|
||||
|
||||
Camera::Camera(const Point2f& position, float scale) : m_Position { position }, m_Scale { scale } {
|
||||
Camera::Camera(const Vector2f& position, float scale) : m_Position { position }, m_Scale { scale } {
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ void Camera::EndRendering() const {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
Point2f Camera::TransformMouse(const Point2f& mousePos) const {
|
||||
Point2f worldPos = mousePos;
|
||||
Vector2f Camera::TransformMouse(const Vector2f& mousePos) const {
|
||||
Vector2f worldPos = mousePos;
|
||||
worldPos.x = ( worldPos.x + m_Position.x ) / m_Scale;
|
||||
worldPos.y = Viewport.height - worldPos.y + m_Position.y / m_Scale;
|
||||
return worldPos;
|
||||
}
|
||||
Point2f Camera::TransformWorld(const Point2f& worldPos) const {
|
||||
Point2f screenPos = worldPos;
|
||||
Vector2f Camera::TransformWorld(const Vector2f& worldPos) const {
|
||||
Vector2f screenPos = worldPos;
|
||||
screenPos.x = screenPos.x * m_Scale - m_Position.x;
|
||||
screenPos.y = Viewport.height - screenPos.y * m_Scale - m_Position.y;
|
||||
return screenPos;
|
||||
|
||||
@@ -6,20 +6,20 @@ class Camera
|
||||
{
|
||||
public:
|
||||
Camera();
|
||||
Camera(const Point2f& position, float scale = 1);
|
||||
Camera(const Vector2f& position, float scale = 1);
|
||||
~Camera() = default;
|
||||
|
||||
Camera(const Camera& other) = default;
|
||||
Camera& operator=(const Camera& other) = default;
|
||||
|
||||
void SetPosition(const Point2f& position) {
|
||||
void SetPosition(const Vector2f& position) {
|
||||
m_Position = position;
|
||||
}
|
||||
void SetScale(const float scale) {
|
||||
m_Scale = scale;
|
||||
}
|
||||
|
||||
const Point2f& GetPosition() const {
|
||||
const Vector2f& GetPosition() const {
|
||||
return m_Position;
|
||||
}
|
||||
float GetScale() const {
|
||||
@@ -33,13 +33,13 @@ public:
|
||||
m_FollowingPlayer = player;
|
||||
}
|
||||
|
||||
Point2f TransformMouse(const Point2f& mousePos) const;
|
||||
Point2f TransformWorld(const Point2f& worldPos) const;
|
||||
Vector2f TransformMouse(const Vector2f& mousePos) const;
|
||||
Vector2f TransformWorld(const Vector2f& worldPos) const;
|
||||
Rectf Viewport = Rectf { 0, 0, 846.f, 500.f };
|
||||
//TODO: Remove this and make it some static
|
||||
|
||||
private:
|
||||
Point2f m_Position;
|
||||
Vector2f m_Position;
|
||||
float m_Scale;
|
||||
Player* m_FollowingPlayer { nullptr };
|
||||
//TODO: Ask if the rule applies to the fact that the player is not managed by the camera
|
||||
|
||||
@@ -22,7 +22,7 @@ Game::~Game() {
|
||||
}
|
||||
|
||||
void Game::Initialize() {
|
||||
m_Camera.SetPosition(Point2f { -GetViewPort().width / 2, -GetViewPort().height / 2 });
|
||||
m_Camera.SetPosition(Vector2f { -GetViewPort().width / 2, -GetViewPort().height / 2 });
|
||||
}
|
||||
|
||||
void Game::Cleanup() {
|
||||
@@ -32,8 +32,8 @@ void Game::Update(float elapsedSec) {
|
||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
if (m_IsRightMouseDown) {
|
||||
const Point2f newCameraPos = Point2f { m_MousePos.x + m_MouseOffset.x, m_MousePos.y + m_MouseOffset.y };
|
||||
m_Camera.SetPosition(Point2f { -newCameraPos.x, -newCameraPos.y });
|
||||
const Vector2f newCameraPos = Vector2f { m_MousePos.x + m_MouseOffset.x, m_MousePos.y + m_MouseOffset.y };
|
||||
m_Camera.SetPosition(Vector2f { -newCameraPos.x, -newCameraPos.y });
|
||||
}
|
||||
else {
|
||||
m_MouseOffset = m_Camera.GetPosition();
|
||||
@@ -56,15 +56,15 @@ void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
|
||||
}
|
||||
|
||||
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
||||
m_MousePos = Point2f { float(e.x), float(e.y) };
|
||||
m_pCurrentLevel->MouseMove(Point2f { float(e.x), float(e.y) });
|
||||
m_MousePos = Vector2f { float(e.x), float(e.y) };
|
||||
m_pCurrentLevel->MouseMove(Vector2f { float(e.x), float(e.y) });
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
||||
m_IsRightMouseDown = e.button == SDL_BUTTON_RIGHT;
|
||||
m_MouseOffset = Point2f { -m_Camera.GetPosition().x - m_MousePos.x, -m_Camera.GetPosition().y - m_MousePos.y };
|
||||
m_MouseOffset = Vector2f { -m_Camera.GetPosition().x - m_MousePos.x, -m_Camera.GetPosition().y - m_MousePos.y };
|
||||
}
|
||||
|
||||
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
||||
|
||||
@@ -42,8 +42,8 @@ private:
|
||||
|
||||
Level* m_pCurrentLevel;
|
||||
|
||||
Point2f m_MousePos {};
|
||||
Point2f m_MouseOffset {};
|
||||
Vector2f m_MousePos {};
|
||||
Vector2f m_MouseOffset {};
|
||||
bool m_IsRightMouseDown {};
|
||||
|
||||
};
|
||||
|
||||
@@ -18,8 +18,8 @@ WorldGridManager::~WorldGridManager() {
|
||||
}
|
||||
surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_tile) {
|
||||
surroundingTiles tiles;
|
||||
Point2f pos = world_tile->GetPosition();
|
||||
Point2f gridCoords = this->GetIndexFromPosition(pos);
|
||||
Vector2f pos = world_tile->GetPosition();
|
||||
Vector2f gridCoords = this->GetIndexFromPosition(pos);
|
||||
int x = gridCoords.x;
|
||||
//TODO: Stupid fix, fix this
|
||||
int y = gridCoords.y - 1;
|
||||
@@ -38,10 +38,10 @@ surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_ti
|
||||
return tiles;
|
||||
|
||||
}
|
||||
Point2f WorldGridManager::GetIndexFromPosition(Point2f position) {
|
||||
Vector2f WorldGridManager::GetIndexFromPosition(Vector2f position) {
|
||||
int x = int(position.x / TILE_WIDTH + WORLD_WIDTH / 2);
|
||||
int y = int(-position.y / TILE_HEIGHT);
|
||||
return Point2f{ float(x), float(y) };
|
||||
return Vector2f{ float(x), float(y) };
|
||||
}
|
||||
WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
|
||||
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
|
||||
@@ -50,7 +50,7 @@ WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
|
||||
}
|
||||
return m_worldTiles[x][y];
|
||||
}
|
||||
WorldTile * WorldGridManager::GetTileAtWorldPos(const Point2f& pos) const {
|
||||
WorldTile * WorldGridManager::GetTileAtWorldPos(const Vector2f& pos) const {
|
||||
int x = int(pos.x / TILE_WIDTH + WORLD_WIDTH / 2);
|
||||
int y = int(-pos.y / TILE_HEIGHT);
|
||||
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
|
||||
|
||||
@@ -48,12 +48,12 @@ public:
|
||||
WorldGridManager();
|
||||
~WorldGridManager();
|
||||
surroundingTiles GetSurroundingTiles(const WorldTile* world_tile);
|
||||
Point2f GetIndexFromPosition(Point2f position);
|
||||
Vector2f GetIndexFromPosition(Vector2f position);
|
||||
|
||||
WorldGridManager(const WorldGridManager& other) = default;
|
||||
|
||||
WorldTile * GetTileAtIndex(const int x, const int y) const;
|
||||
WorldTile * GetTileAtWorldPos(const Point2f& pos) const;
|
||||
WorldTile * GetTileAtWorldPos(const Vector2f& pos) const;
|
||||
|
||||
void SetTileAtIndex(const int x, const int y, WorldTile* tile);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "WorldGridManager.h"
|
||||
|
||||
|
||||
WorldTile::WorldTile(const Point2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager) : m_Position { position }, m_GroundTileType { groundTileType }, m_pGridManager { pGridManager } {
|
||||
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";
|
||||
// m_pTexture = new Texture(dirtPath);
|
||||
m_pTexture = pTextureManager->GetTexture(groundTileType->getPath());
|
||||
@@ -140,12 +140,12 @@ void WorldTile::Draw() {
|
||||
// GroundTileTypes type = tile->GetTileType()->getType();
|
||||
// if(type == Tiles::AIR->getType()) {
|
||||
// utils::SetColor(Colors::BLACK);
|
||||
// utils::FillRect(Rectf{tile->GetPosition(), Point2f{50,50}});
|
||||
// utils::FillRect(Rectf{tile->GetPosition(), Vector2f{50,50}});
|
||||
// continue;
|
||||
// }
|
||||
// if(type != Tiles::AIR->getType()) {
|
||||
// utils::SetColor(Colors::YELLOW);
|
||||
// utils::FillRect(Rectf{tile->GetPosition(), Point2f{50,50}});
|
||||
// utils::FillRect(Rectf{tile->GetPosition(), Vector2f{50,50}});
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -176,7 +176,7 @@ void WorldTile::Draw() {
|
||||
// if(topLeftType != Tiles::AIR) {
|
||||
// m_pTopLeftTexture->Draw(m_Position);
|
||||
// utils::SetColor(Colors::YELLOW);
|
||||
// utils::FillRect(Rectf{topLeft->GetPosition(), Point2f{50,50}});
|
||||
// utils::FillRect(Rectf{topLeft->GetPosition(), Vector2f{50,50}});
|
||||
// }
|
||||
//
|
||||
// WorldTile* topRight = m_SurroundingTiles.GetTile(TileDirection::TopRight);
|
||||
@@ -187,9 +187,9 @@ void WorldTile::Draw() {
|
||||
//
|
||||
}
|
||||
void WorldTile::Update(Camera* camera) {
|
||||
Point2f CurrentIndex = m_pGridManager->GetIndexFromPosition(m_Position);
|
||||
Vector2f CurrentIndex = m_pGridManager->GetIndexFromPosition(m_Position);
|
||||
m_SurroundingTiles = m_pGridManager->GetSurroundingTiles(this);
|
||||
Point2f mousePos = camera->TransformMouse(Point2f{utils::GetMousePos().x, 500 - utils::GetMousePos().y});
|
||||
Vector2f mousePos = camera->TransformMouse(Vector2f{utils::GetMousePos().x, 500 - utils::GetMousePos().y});
|
||||
m_Hightlight = utils::IsPointInRect(mousePos, Rectf{GetCollisionRect().pos, GetCollisionRect().size});
|
||||
if(CurrentIndex.x == 1 && CurrentIndex.y == 1) {
|
||||
// std::cout << "Hey" << std::endl;
|
||||
|
||||
@@ -95,21 +95,21 @@ class WorldTile
|
||||
{
|
||||
public:
|
||||
WorldTile() = default;
|
||||
WorldTile(const Point2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager);
|
||||
WorldTile(const Vector2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager);
|
||||
~WorldTile();
|
||||
|
||||
void Draw();
|
||||
void Update(Camera* camera); //TODO: no use
|
||||
|
||||
Point2f GetPosition() const {
|
||||
Vector2f GetPosition() const {
|
||||
return m_Position;
|
||||
}
|
||||
void SetPosition(const Point2f& position) {
|
||||
void SetPosition(const Vector2f& position) {
|
||||
m_Position = position;
|
||||
}
|
||||
|
||||
Point2f GetSize() const {
|
||||
return Point2f { 50, 50 };
|
||||
Vector2f GetSize() const {
|
||||
return Vector2f { 50, 50 };
|
||||
}
|
||||
|
||||
GroundTileType * GetTileType() const {
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
bool m_Hightlight { false };
|
||||
|
||||
private:
|
||||
Point2f m_Position;
|
||||
Vector2f m_Position;
|
||||
GroundTileType* m_GroundTileType;
|
||||
|
||||
Texture* m_pTexture;
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
#include "colors.h"
|
||||
#include "utils.h"
|
||||
Button::Button(const std::string& filePath, Point2f pos, Point2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
|
||||
Button::Button(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
|
||||
m_Texture = manager->GetTexture(filePath);
|
||||
if(size.x == 0 && size.y == 0) {
|
||||
m_Size = Point2f{float(m_Texture->GetWidth()), float(m_Texture->GetHeight())};
|
||||
m_Size = Vector2f{float(m_Texture->GetWidth()), float(m_Texture->GetHeight())};
|
||||
}
|
||||
std::cout << "Button created" << '\n';
|
||||
}
|
||||
@@ -23,7 +23,7 @@ void Button::Draw() const {
|
||||
}
|
||||
}
|
||||
void Button::Update(float elapsedSec) {
|
||||
Point2f mousePos = utils::GetMousePos();
|
||||
Vector2f mousePos = utils::GetMousePos();
|
||||
Rectf buttonRect = Rectf(m_Position, m_Size);
|
||||
|
||||
this->m_IsHovered = utils::IsPointInRect(mousePos, buttonRect);
|
||||
|
||||
@@ -9,7 +9,7 @@ class Button
|
||||
{
|
||||
public:
|
||||
Button() = default;
|
||||
Button(const std::string& filePath, Point2f pos, Point2f size, TextureManager* manager);
|
||||
Button(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
|
||||
~Button();
|
||||
void Draw() const;
|
||||
void Update(float elapsedSec);
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
|
||||
private:
|
||||
Texture* m_Texture{ nullptr };
|
||||
Point2f m_Position;
|
||||
Point2f m_Size;
|
||||
Vector2f m_Position;
|
||||
Vector2f m_Size;
|
||||
|
||||
bool m_IsHovered{ false };
|
||||
bool m_IsPressed{ false };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "Screen.h"
|
||||
|
||||
Screen::Screen(const std::string& filePath, Point2f pos, Point2f 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) {
|
||||
m_Background = manager->GetTexture(filePath);
|
||||
}
|
||||
Screen::~Screen() {
|
||||
|
||||
@@ -10,7 +10,7 @@ class Screen
|
||||
{
|
||||
public:
|
||||
Screen() = default;
|
||||
Screen(const std::string& filePath, Point2f pos, Point2f size, TextureManager* manager);
|
||||
Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
|
||||
|
||||
virtual ~Screen();
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
virtual void Update(float elapsedSecs);
|
||||
virtual void Draw() const;
|
||||
private:
|
||||
Point2f m_Position;
|
||||
Point2f m_Size;
|
||||
Vector2f m_Position;
|
||||
Vector2f m_Size;
|
||||
|
||||
Texture* m_Background{ nullptr };
|
||||
|
||||
|
||||
@@ -3,40 +3,40 @@
|
||||
|
||||
#include "ScreenManager.h"
|
||||
#include "utils.h"
|
||||
FuelScreen::FuelScreen(const std::string& filePath, Point2f pos, Point2f size, TextureManager* manager): Screen(filePath, pos, size, manager)
|
||||
FuelScreen::FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager)
|
||||
{
|
||||
Point2f fuelScreenSize = Point2f { 492, 396 };
|
||||
Point2f fuelScreenCenter = Point2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
|
||||
const Vector2f fuelScreenSize = Vector2f { 492, 396 };
|
||||
// Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
|
||||
const Vector2f ScreenCenter = Vector2f { utils::GetViewport().x / 2, utils::GetViewport().y / 2 };
|
||||
|
||||
Point2f closeButtonOffset = Point2f { 460, 396 - 14 };
|
||||
Point2f closeButtonPos = fuelScreenCenter + closeButtonOffset;
|
||||
const Vector2f fuelScreenCenter = ScreenCenter - fuelScreenSize / 2;
|
||||
|
||||
|
||||
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
|
||||
Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset;
|
||||
closeButtonPos.y -= 18;
|
||||
Button* closeFuelButton = new Button { "gui/close.png", closeButtonPos, Point2f{0,0}, TextureManager::GetInstance() };
|
||||
Button* closeFuelButton = new Button { "gui/close.png", closeButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||
closeFuelButton->SetOnClick([this]() { ScreenManager::GetInstance()->CloseScreen(); });
|
||||
this->AddButton(closeFuelButton);
|
||||
|
||||
Point2f oneDollarButtonPos = Point2f { 451, 287 };
|
||||
oneDollarButtonPos += fuelScreenCenter;
|
||||
Button* fiveDollarButton = new Button { "gui/fuel/5dollars.png", oneDollarButtonPos , Point2f{0,0}, TextureManager::GetInstance() };
|
||||
const Vector2f oneDollarButtonPos = Vector2f { 451, 287 };
|
||||
Button* fiveDollarButton = new Button { "gui/fuel/5dollars.png", oneDollarButtonPos , Vector2f{0,0}, TextureManager::GetInstance() };
|
||||
this->AddButton(fiveDollarButton);
|
||||
|
||||
Point2f tenDollarButtonPos = oneDollarButtonPos + Point2f { 113, -1 };
|
||||
tenDollarButtonPos += fuelScreenCenter;
|
||||
Button* tenDollarButton = new Button { "gui/fuel/10dollars.png", tenDollarButtonPos, Point2f{0,0}, TextureManager::GetInstance() };
|
||||
const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 };
|
||||
Button* tenDollarButton = new Button { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||
this->AddButton(tenDollarButton);
|
||||
|
||||
Point2f twentyFiveDollarButtonPos = oneDollarButtonPos + Point2f { 0, -89 };
|
||||
twentyFiveDollarButtonPos += fuelScreenCenter;
|
||||
Button* twentyFiveDollarButton = new Button { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Point2f{0,0}, TextureManager::GetInstance() };
|
||||
const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 };
|
||||
Button* twentyFiveDollarButton = new Button { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||
this->AddButton(twentyFiveDollarButton);
|
||||
|
||||
Point2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Point2f { 114, 0 };
|
||||
Button* fiftyDollarButton = new Button { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Point2f{0,0}, TextureManager::GetInstance() };
|
||||
const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 };
|
||||
Button* fiftyDollarButton = new Button { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||
this->AddButton(fiftyDollarButton);
|
||||
|
||||
Point2f fillTankButtonPos = Point2f { 450, 108 };
|
||||
fillTankButtonPos += fuelScreenCenter;
|
||||
Button* fillTankButton = new Button { "gui/fuel/fillTank.png", fillTankButtonPos, Point2f{0,0}, TextureManager::GetInstance() };
|
||||
const Vector2f fillTankButtonPos = Vector2f { 450, 108 };
|
||||
Button* fillTankButton = new Button { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
|
||||
this->AddButton(fillTankButton);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class FuelScreen : public Screen
|
||||
{
|
||||
public:
|
||||
|
||||
FuelScreen(const std::string& filePath, Point2f pos, Point2f size, TextureManager* manager);
|
||||
FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
|
||||
|
||||
virtual void Draw() const override;
|
||||
virtual void Update(float elapsedSecs) override;
|
||||
|
||||
@@ -34,12 +34,12 @@ void ScreenManager::CloseScreen() {
|
||||
|
||||
}
|
||||
void ScreenManager::InitializeScreens() {
|
||||
Point2f fuelScreenSize = Point2f { 492, 396 };
|
||||
Point2f fuelScreenCenter = Point2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
|
||||
Fuel = new FuelScreen { "gui/fuel/background.png", fuelScreenCenter, Point2f { 0, 0 }, TextureManager::GetInstance() };
|
||||
Vector2f fuelScreenSize = Vector2f { 492, 396 };
|
||||
Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
|
||||
Fuel = new FuelScreen { "gui/fuel/background.png", fuelScreenCenter, Vector2f { 0, 0 }, TextureManager::GetInstance() };
|
||||
|
||||
Point2f sellScreenSize = Point2f { 533, 398 };
|
||||
Point2f sellScreenCenter = Point2f { utils::GetViewport().x / 2 - sellScreenSize.x / 2, utils::GetViewport().y / 2 - sellScreenSize.y / 2 };
|
||||
Vector2f sellScreenSize = Vector2f { 533, 398 };
|
||||
Vector2f sellScreenCenter = Vector2f { utils::GetViewport().x / 2 - sellScreenSize.x / 2, utils::GetViewport().y / 2 - sellScreenSize.y / 2 };
|
||||
SellScreen = new Screen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, TextureManager::GetInstance() };
|
||||
|
||||
//m_Button = Button { "gui/close.png", closeButtonPos, closeButtonSize, TextureManager::GetInstance() };
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
|
||||
virtual void Update(float elapsedSec) = 0;
|
||||
virtual void Draw() const = 0;
|
||||
virtual void MouseMove(const Point2f& mousePos) = 0;
|
||||
virtual void MouseMove(const Vector2f& mousePos) = 0;
|
||||
virtual void ProcessImGui() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -16,12 +16,12 @@ MainMenuLevel::~MainMenuLevel() {
|
||||
void MainMenuLevel::Update(float elapsedSec) {
|
||||
}
|
||||
void MainMenuLevel::Draw() const {
|
||||
m_TextMotherload->Draw(Point2f(200, 100));
|
||||
m_TextNewGame->Draw(Point2f(200, 200));
|
||||
m_TextExit->Draw(Point2f(200, 300));
|
||||
m_TextMotherload->Draw(Vector2f(200, 100));
|
||||
m_TextNewGame->Draw(Vector2f(200, 200));
|
||||
m_TextExit->Draw(Vector2f(200, 300));
|
||||
|
||||
}
|
||||
void MainMenuLevel::MouseMove(const Point2f& mousePos) {
|
||||
void MainMenuLevel::MouseMove(const Vector2f& mousePos) {
|
||||
}
|
||||
void MainMenuLevel::ProcessImGui() {
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
|
||||
void Update(float elapsedSec) override;
|
||||
void Draw() const override;
|
||||
void MouseMove(const Point2f& mousePos) override;
|
||||
void MouseMove(const Vector2f& mousePos) override;
|
||||
void ProcessImGui() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class GroundTileType;
|
||||
WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_gridManager(WorldGridManager()),
|
||||
m_player(Player { Point2f { 0, 100 }, TextureManager::GetInstance() }),
|
||||
m_player(Player { Vector2f { 0, 100 }, TextureManager::GetInstance() }),
|
||||
m_mousePos { 0, 0 },
|
||||
m_viewport(viewport),
|
||||
m_screenManager(ScreenManager::GetInstance()) {
|
||||
@@ -24,7 +24,7 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
const int actualX = x - WORLD_WIDTH / 2;
|
||||
Point2f pos = Point2f { 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 = Tiles::AIR;
|
||||
switch (utils::randRange(0, 2)) {
|
||||
case 0:
|
||||
@@ -54,7 +54,7 @@ WorldLevel::~WorldLevel() {
|
||||
void WorldLevel::Update(float elapsedSec) {
|
||||
int mouseX, mouseY;
|
||||
SDL_GetMouseState(&mouseX, &mouseY);
|
||||
m_mousePos = Point2f { float(mouseX), float(mouseY) };
|
||||
m_mousePos = Vector2f { float(mouseX), float(mouseY) };
|
||||
m_mousePos = m_pCamera->TransformMouse(m_mousePos);
|
||||
|
||||
|
||||
@@ -101,12 +101,12 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
screen->Update(elapsedSec);
|
||||
}
|
||||
|
||||
//Point2f playerPos = m_player.GetPosition();
|
||||
//Point2f newCameraPos = playerPos;
|
||||
//Vector2f playerPos = m_player.GetPosition();
|
||||
//Vector2f newCameraPos = playerPos;
|
||||
//m_pCamera->SetPosition(newCameraPos);
|
||||
|
||||
//place the player in the center of the camera
|
||||
//m_pCamera->SetPosition(Point2f{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 {
|
||||
@@ -141,7 +141,7 @@ void WorldLevel::Draw() const {
|
||||
screen->Draw();
|
||||
}
|
||||
}
|
||||
void WorldLevel::MouseMove(const Point2f& mousePos) {
|
||||
void WorldLevel::MouseMove(const Vector2f& mousePos) {
|
||||
m_mousePos = mousePos;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ void WorldLevel::ProcessImGui() {
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
const Point2f screenPos = utils::GetMousePos();
|
||||
const Vector2f screenPos = utils::GetMousePos();
|
||||
const std::string mousePos = "Mouse Pos: (" + std::to_string(screenPos.x) + ", " + std::to_string(screenPos.y) + ")";
|
||||
if(ImGui::BeginMenu(mousePos.c_str())) {
|
||||
|
||||
@@ -198,7 +198,7 @@ void WorldLevel::ProcessImGui() {
|
||||
ImGui::Text("Camera Position: (%f, %f)", m_pCamera->GetPosition().x, m_pCamera->GetPosition().y);
|
||||
ImGui::Text("Is Right Mouse Down: %s", utils::isMouseDown(0) ? "true" : "false");
|
||||
if (ImGui::Button("Reset Camera")) {
|
||||
m_pCamera->SetPosition(Point2f { -m_viewport.width / 2, -m_viewport.height / 2 });
|
||||
m_pCamera->SetPosition(Vector2f { -m_viewport.width / 2, -m_viewport.height / 2 });
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void Update(float elapsedSec) override;
|
||||
void Draw() const override;
|
||||
|
||||
void MouseMove(const Point2f& mousePos) override;
|
||||
void MouseMove(const Vector2f& mousePos) override;
|
||||
void ProcessImGui() override;
|
||||
|
||||
WorldGridManager& GetGridManager() {
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
private:
|
||||
WorldGridManager m_gridManager {};
|
||||
Player m_player;
|
||||
Point2f m_mousePos {};
|
||||
Vector2f m_mousePos {};
|
||||
|
||||
Rectf m_viewport;
|
||||
|
||||
@@ -38,6 +38,8 @@ private:
|
||||
|
||||
WorldTile* m_pSelectedTile { nullptr };
|
||||
|
||||
float testLerp{ 0.0f };
|
||||
|
||||
// ImGui Vars
|
||||
bool m_ShowTextureManagerWindow { false };
|
||||
bool m_ShowCameraWindow { false };
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "Animations/Animation.h"
|
||||
#include "GridSystem/WorldTile.h"
|
||||
|
||||
Player::Player(const Point2f& Position, TextureManager* manager) : m_Position(Position), m_Size(Point2f { 40, 40 }), m_Vel(Point2f { 0, 0 }), m_Acc(Point2f { 0, 0 }) {
|
||||
Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(Position), m_Size(Vector2f { 40, 40 }), m_Vel(Vector2f { 0, 0 }), m_Acc(Vector2f { 0, 0 }) {
|
||||
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
|
||||
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
|
||||
m_ContactMap[Collision::CollisionDirection::Left] = nullptr;
|
||||
@@ -30,12 +30,12 @@ void Player::Draw() const {
|
||||
utils::SetColor(Colors::PINK);
|
||||
utils::DrawRect(Rectf { m_Position.x, m_Position.y, m_Size.x, m_Size.y });
|
||||
}
|
||||
Point2f center = m_Position + m_Size / 2;
|
||||
Vector2f center = m_Position + m_Size / 2;
|
||||
|
||||
const int frameWidth = 70; //TODO: fix this
|
||||
int halfFrameWidth = frameWidth / 2;
|
||||
|
||||
Point2f drawPos = Point2f { center.x - halfFrameWidth, center.y - halfFrameWidth + 9 };
|
||||
Vector2f drawPos = Vector2f { center.x - halfFrameWidth, center.y - halfFrameWidth + 9 };
|
||||
|
||||
m_walkAnimation->Draw(drawPos, Rectf { drawPos.x, drawPos.y, frameWidth, frameWidth });
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
|
||||
//check for keys
|
||||
if(m_State != PlayerState::Digging) {
|
||||
m_Vel = Point2f { 0, -100 };
|
||||
m_Vel = Vector2f { 0, -100 };
|
||||
if (utils::isKeyDown(SDL_SCANCODE_W)) {
|
||||
m_Vel.y = 100;
|
||||
m_Grounded = false;
|
||||
@@ -83,14 +83,11 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
if (m_ContactMap[Collision::CollisionDirection::Bottom] != nullptr) {
|
||||
//Do the digging
|
||||
m_State = PlayerState::Digging;
|
||||
m_DigProgress = 0;
|
||||
m_DigTile = m_ContactMap[Collision::CollisionDirection::Bottom];
|
||||
//Set the digging location in the center of the destination tile;
|
||||
WorldTile* tile = m_ContactMap[Collision::CollisionDirection::Bottom];
|
||||
m_DigDestination = tile->GetPosition() + tile->GetSize() / 2;
|
||||
m_ContactMap[Collision::CollisionDirection::Bottom]->SetTileType(Tiles::AIR);
|
||||
//center of tile
|
||||
Point2f tileCenter = tile->GetCollisionRect().getCollisionRect().pos + tile->GetCollisionRect().getCollisionRect().size / 2;
|
||||
m_Position = Point2f { tileCenter.x - m_Size.x / 2, tileCenter.y - m_Size.y / 2 + 5 };
|
||||
|
||||
const WorldTile* tile = m_ContactMap[Collision::CollisionDirection::Bottom];
|
||||
m_DigDestination = tile->GetPosition() + Vector2f{0, 0};
|
||||
m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -108,8 +105,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
m_ContactMap[Collision::CollisionDirection::Right]->SetTileType(Tiles::AIR);
|
||||
WorldTile* tile = m_ContactMap[Collision::CollisionDirection::Right];
|
||||
//center of tile
|
||||
const Point2f tileCenter = tile->GetCollisionRect().getCollisionRect().pos + tile->GetCollisionRect().getCollisionRect().size / 2;
|
||||
m_Position = Point2f { tileCenter.x - m_Size.x / 2, tileCenter.y - m_Size.y / 2 + 5 };
|
||||
const Vector2f tileCenter = tile->GetCollisionRect().getCollisionRect().pos + tile->GetCollisionRect().getCollisionRect().size / 2;
|
||||
m_Position = Vector2f { tileCenter.x - m_Size.x / 2, tileCenter.y - m_Size.y / 2 + 5 };
|
||||
|
||||
m_ContactMap[Collision::CollisionDirection::Right] = nullptr;
|
||||
m_DidJustDigRight = true;
|
||||
@@ -133,7 +130,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
|
||||
|
||||
float t = 0, min_t = INFINITY;
|
||||
Point2f intersectionPoint, normal;
|
||||
Vector2f intersectionPoint, normal;
|
||||
|
||||
std::vector<std::pair<int, float>> contactTimes {};
|
||||
|
||||
@@ -161,8 +158,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
int y = contact_time.first / WORLD_WIDTH;
|
||||
WorldTile* world_tile = gridManager.GetTileAtIndex(x, y);
|
||||
|
||||
const Point2f WorldTilePos = world_tile->GetCollisionRect().getCollisionRect().pos;
|
||||
const Point2f WorldTileSize = world_tile->GetCollisionRect().getCollisionRect().size;
|
||||
const Vector2f WorldTilePos = world_tile->GetCollisionRect().getCollisionRect().pos;
|
||||
const Vector2f WorldTileSize = world_tile->GetCollisionRect().getCollisionRect().size;
|
||||
|
||||
if (WorldTilePos.y + WorldTileSize.y > m_Position.y) {
|
||||
if (WorldTilePos.x + WorldTileSize.x > m_Position.x) {
|
||||
@@ -211,8 +208,25 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
|
||||
case PlayerState::Walking:
|
||||
m_walkAnimation->SetPlaying(true);
|
||||
break;
|
||||
case PlayerState::Digging:
|
||||
case PlayerState::Digging: {
|
||||
m_walkAnimation->SetPlaying(false);
|
||||
//Diganimation
|
||||
m_DigProgress += elapsedTime;
|
||||
//lerp to the destination
|
||||
float progress = utils::map(m_DigProgress, 0.0f, m_DigTime, 0.0f, 1.0f);
|
||||
std::cout << progress << '\n';
|
||||
m_Position = utils::lerp(m_Position, m_DigDestination, progress);
|
||||
if (progress >= 0.5f && !m_HasDeletedTile) {
|
||||
m_DigTile->SetTileType(Tiles::AIR);
|
||||
m_DigTile = nullptr;
|
||||
m_HasDeletedTile = true;
|
||||
}
|
||||
if (progress >= 1.0f) {
|
||||
m_State = PlayerState::Idle;
|
||||
m_HasDeletedTile = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
@@ -30,22 +30,22 @@ enum class DigDirection
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
Player(const Point2f& Position, TextureManager* pTextureManager);
|
||||
Player(const Vector2f& Position, TextureManager* pTextureManager);
|
||||
Collision::CollisionRect GetCollisionRect() const;
|
||||
void Update(float elapsedTime, WorldLevel& level);
|
||||
void Draw() const;
|
||||
|
||||
void SetPosition(Point2f pos) {
|
||||
void SetPosition(Vector2f pos) {
|
||||
m_Position = pos;
|
||||
}
|
||||
Point2f GetPosition() const {
|
||||
Vector2f GetPosition() const {
|
||||
return m_Position;
|
||||
}
|
||||
|
||||
void SetVelocity(Point2f vel) {
|
||||
void SetVelocity(Vector2f vel) {
|
||||
m_Vel = vel;
|
||||
}
|
||||
Point2f GetVelocity() const {
|
||||
Vector2f GetVelocity() const {
|
||||
return m_Vel;
|
||||
}
|
||||
|
||||
@@ -59,17 +59,22 @@ public:
|
||||
void ProcessImGui();
|
||||
|
||||
private:
|
||||
Point2f m_Position;
|
||||
Point2f m_Size;
|
||||
Vector2f m_Position;
|
||||
Vector2f m_Size;
|
||||
|
||||
Point2f m_Vel;
|
||||
Vector2f m_Vel;
|
||||
|
||||
std::map<Collision::CollisionDirection, WorldTile *> m_ContactMap;
|
||||
|
||||
Point2f m_Acc;
|
||||
Point2f m_Gravity { 0, -9.81f };
|
||||
Vector2f m_Acc;
|
||||
Vector2f m_Gravity { 0, -9.81f };
|
||||
|
||||
Point2f m_DigDestination{};
|
||||
Vector2f m_DigDestination{};
|
||||
float m_DigProgress{};
|
||||
bool m_HasDeletedTile{ false };
|
||||
WorldTile* m_DigTile{ nullptr };
|
||||
|
||||
const float m_DigTime{ 1.0f };
|
||||
|
||||
bool m_Grounded { false };
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
void StartHeapControl();
|
||||
void DumpMemoryLeaks();
|
||||
|
||||
Point2f Viewport { 900.f, 500.f };
|
||||
Vector2f Viewport { 900.f, 500.f };
|
||||
|
||||
int SDL_main(int argv, char** args) {
|
||||
srand(static_cast<unsigned int>(time(nullptr)));
|
||||
|
||||
Reference in New Issue
Block a user