mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-15 11:41:48 +01:00
Add sun / moon, started on score / GameManager
This commit is contained in:
71
.idea/.idea.Motherload/.idea/workspace.xml
generated
71
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -11,21 +11,16 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/Game/Gui/GuiText.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Gui/GuiText.h" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Levels/World/OrbitingObject.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Levels/World/OrbitingObject.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/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$/Game/Game.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GroundTileTypeManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/GroundTileTypeManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GroundTileTypeManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/GroundTileTypeManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GameManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GameManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GameManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GameManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Gui/Screens/MainScreen.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/Building.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/Building.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Resources/gui/main/fuel/fuel.png" beforeDir="false" afterPath="$PROJECT_DIR$/Resources/gui/main/fuel/fuel.png" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -40,6 +35,10 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include/algorithm" root0="SKIP_HIGHLIGHTING" />
|
||||
@@ -52,6 +51,7 @@
|
||||
<setting file="file://$PROJECT_DIR$/Engine/utils.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Engine/utils.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/Levels/World/Building.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Player.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Player.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/pch.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
@@ -78,28 +78,28 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"C++ Project.Game.executor": "Debug",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"C++ Project.Game.executor": "Debug",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
||||
]
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Game" type="CppProject" factoryName="C++ Project">
|
||||
<configuration_1>
|
||||
@@ -250,7 +250,7 @@
|
||||
<workItem from="1715669033601" duration="11720000" />
|
||||
<workItem from="1715762731245" duration="3986000" />
|
||||
<workItem from="1715773968873" duration="3580000" />
|
||||
<workItem from="1715814533138" duration="3223000" />
|
||||
<workItem from="1715814533138" duration="12142000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||
<option name="closed" value="true" />
|
||||
@@ -396,7 +396,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715255455692</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="19" />
|
||||
<task id="LOCAL-00019" summary="Add Text rendering and Hull / Fuel Meters">
|
||||
<option name="closed" value="true" />
|
||||
<created>1715817878533</created>
|
||||
<option name="number" value="00019" />
|
||||
<option name="presentableId" value="LOCAL-00019" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715817878533</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="20" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -423,7 +431,8 @@
|
||||
<MESSAGE value="Fix digging" />
|
||||
<MESSAGE value="Started on GuiIcon, General fixes" />
|
||||
<MESSAGE value="Add Particles (basic)" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Add Particles (basic)" />
|
||||
<MESSAGE value="Add Text rendering and Hull / Fuel Meters" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Add Text rendering and Hull / Fuel Meters" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
||||
@@ -539,6 +539,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="Levels\MainMenu\MainMenuLevel.cpp" />
|
||||
<ClCompile Include="Levels\World\Building.cpp" />
|
||||
<ClCompile Include="Levels\World\OrbitingObject.cpp" />
|
||||
<ClCompile Include="Levels\World\WorldLevel.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
@@ -639,6 +640,7 @@
|
||||
<ClInclude Include="Levels\Level.h" />
|
||||
<ClInclude Include="Levels\MainMenu\MainMenuLevel.h" />
|
||||
<ClInclude Include="Levels\World\Building.h" />
|
||||
<ClInclude Include="Levels\World\OrbitingObject.h" />
|
||||
<ClInclude Include="Levels\World\WorldLevel.h" />
|
||||
<ClInclude Include="Particle\Particle.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
|
||||
@@ -1,2 +1,50 @@
|
||||
#include "pch.h"
|
||||
#include "GameManager.h"
|
||||
|
||||
GameManager* GameManager::m_pInstance = nullptr;
|
||||
|
||||
GameManager& GameManager::GetInstance() {
|
||||
if (m_pInstance == nullptr) {
|
||||
m_pInstance = new GameManager();
|
||||
}
|
||||
return *m_pInstance;
|
||||
}
|
||||
void GameManager::SetMainScreen(MainScreen* pMainScreen) {
|
||||
m_pMainScreen = pMainScreen;
|
||||
//TODO: not the best but ¯\_(ツ)_/¯
|
||||
}
|
||||
void GameManager::SetFuel(int fuel) {
|
||||
m_Fuel = fuel;
|
||||
}
|
||||
int GameManager::GetFuel() const {
|
||||
return m_Fuel;
|
||||
}
|
||||
void GameManager::DecreaseFuel(int fuel) {
|
||||
m_Fuel -= fuel;
|
||||
}
|
||||
void GameManager::AddFuel(int fuel) {
|
||||
m_Fuel += fuel;
|
||||
}
|
||||
void GameManager::SetHullIntegrity(int hullIntegrity) {
|
||||
m_HullIntegrity = hullIntegrity;
|
||||
}
|
||||
int GameManager::GetHullIntegrity() const {
|
||||
return m_HullIntegrity;
|
||||
}
|
||||
void GameManager::DamageHull(int damage) {
|
||||
m_HullIntegrity -= damage;
|
||||
}
|
||||
void GameManager::SetScore(int score) {
|
||||
m_Score = score;
|
||||
}
|
||||
int GameManager::GetScore() const {
|
||||
return m_Score;
|
||||
}
|
||||
void GameManager::IncreaseScore(int score) {
|
||||
m_Score += score;
|
||||
}
|
||||
void GameManager::Update(float elapsedSecs) {
|
||||
m_pMainScreen->SetFuelMeterValue(m_Fuel);
|
||||
m_pMainScreen->SetHullMeterValue(m_HullIntegrity);
|
||||
m_pMainScreen->SetScore(std::to_string(m_Score));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,38 @@
|
||||
#pragma once
|
||||
#include "Player.h"
|
||||
#include "Gui/Screens/MainScreen.h"
|
||||
|
||||
class GameManager
|
||||
{
|
||||
class GameManager {
|
||||
public:
|
||||
float balance{ 0.0f };
|
||||
float fuel{ 0.0f };
|
||||
static GameManager& GetInstance();
|
||||
static GameManager* m_pInstance;
|
||||
|
||||
|
||||
void SetMainScreen(MainScreen* pMainScreen);
|
||||
|
||||
void SetFuel(int fuel);
|
||||
int GetFuel() const;
|
||||
void DecreaseFuel(int fuel);
|
||||
void AddFuel(int fuel);
|
||||
|
||||
void SetHullIntegrity(int hullIntegrity);
|
||||
int GetHullIntegrity() const;
|
||||
void DamageHull(int damage);
|
||||
|
||||
void SetScore(int score);
|
||||
int GetScore() const;
|
||||
void IncreaseScore(int score);
|
||||
|
||||
void Update(float elapsedSecs);
|
||||
|
||||
private:
|
||||
GameManager() = default;
|
||||
|
||||
|
||||
float m_Balance{ 0.0f };
|
||||
int m_HullIntegrity{ 100 };
|
||||
int m_Fuel{ 100 };
|
||||
int m_Score{ 0 };
|
||||
MainScreen* m_pMainScreen{ nullptr };
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vec
|
||||
Vector2f DepthMeterPosition{10, ScreenSize.y - 120};
|
||||
m_DepthText = new GuiText(DepthMeterPosition, "Depth: 20", "fonts/Arial.ttf", 20, Colors::YELLOW);
|
||||
this->AddElement(m_DepthText);
|
||||
|
||||
Vector2f ScoreMeterPosition{10, ScreenSize.y - 150};
|
||||
m_ScoreText = new GuiText(ScoreMeterPosition, "Score: 0", "fonts/Arial.ttf", 20, Colors::YELLOW);
|
||||
this->AddElement(m_ScoreText);
|
||||
}
|
||||
MainScreen::~MainScreen() = default;
|
||||
void MainScreen::Draw() const {
|
||||
@@ -35,4 +39,7 @@ void MainScreen::SetHullMeterValue(float value) const {
|
||||
void MainScreen::SetDepth(const std::string& text) const {
|
||||
m_DepthText->ChangeText(text);
|
||||
}
|
||||
void MainScreen::SetScore(const std::string& text) const {
|
||||
m_ScoreText->ChangeText(text);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,13 @@ public:
|
||||
void SetHullMeterValue(float value) const;
|
||||
|
||||
void SetDepth(const std::string& text) const;
|
||||
void SetScore(const std::string& text) const;
|
||||
|
||||
private:
|
||||
GuiMeter* m_FuelMeter;
|
||||
GuiMeter* m_HullMeter;
|
||||
|
||||
GuiText* m_DepthText;
|
||||
GuiText* m_ScoreText;
|
||||
|
||||
};
|
||||
|
||||
14
Game/Levels/World/OrbitingObject.cpp
Normal file
14
Game/Levels/World/OrbitingObject.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "pch.h"
|
||||
#include "OrbitingObject.h"
|
||||
|
||||
#include <iostream>
|
||||
OrbitingObject::OrbitingObject(const Vector2f& orbit, float distance, float speed, Texture* texture, float offset): m_Texture(texture), m_Orbit(orbit), m_Speed(speed), m_Distance(distance), m_currentCycle(offset) {
|
||||
}
|
||||
void OrbitingObject::Update(float elapsedSecs) {
|
||||
m_Position = Vector2f(m_Orbit.x + cosf(m_currentCycle) * m_Distance, m_Orbit.y + sinf(m_currentCycle) * m_Distance);
|
||||
m_currentCycle += m_Speed * elapsedSecs;
|
||||
}
|
||||
void OrbitingObject::Draw() const {
|
||||
m_Texture->Draw(m_Position);
|
||||
|
||||
}
|
||||
21
Game/Levels/World/OrbitingObject.h
Normal file
21
Game/Levels/World/OrbitingObject.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Texture.h"
|
||||
|
||||
class OrbitingObject {
|
||||
public:
|
||||
OrbitingObject(const Vector2f& orbit, float distance, float speed, Texture* texture, float offset = 0);
|
||||
|
||||
void Update(float elapsedSecs);
|
||||
void Draw() const;
|
||||
|
||||
|
||||
private:
|
||||
Texture* m_Texture;
|
||||
Vector2f m_Position;
|
||||
Vector2f m_Orbit;
|
||||
float m_Distance;
|
||||
float m_Speed;
|
||||
|
||||
float m_currentCycle{ 0 };
|
||||
|
||||
};
|
||||
@@ -67,6 +67,8 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
|
||||
m_MainScreen = new MainScreen(TextureManager::GetInstance());
|
||||
|
||||
m_Sun = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("sun.png"));
|
||||
m_Moon = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("moon.png"), M_PI);
|
||||
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
@@ -86,6 +88,9 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
// m_gridManager.GetTileAtIndex(x, y)->m_Hightlight = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
m_Sun->Update(elapsedSec);
|
||||
m_Moon->Update(elapsedSec);
|
||||
|
||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
@@ -179,6 +184,9 @@ void WorldLevel::Draw() const {
|
||||
utils::SetColor(Colors::GREEN);
|
||||
utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
|
||||
|
||||
m_Sun->Draw();
|
||||
m_Moon->Draw();
|
||||
|
||||
m_pCamera->EndRendering();
|
||||
|
||||
utils::FillRect(utils::GetMousePos(), 10, 10);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "GridSystem/WorldGridManager.h"
|
||||
#include "Gui/Screens/ScreenManager.h"
|
||||
#include "Camera.h"
|
||||
#include "OrbitingObject.h"
|
||||
#include "Text.h"
|
||||
#include "Gui/GuiMeter.h"
|
||||
#include "Gui/Screens/MainScreen.h"
|
||||
@@ -49,6 +50,9 @@ private:
|
||||
|
||||
MainScreen* m_MainScreen{};
|
||||
|
||||
OrbitingObject* m_Sun{ nullptr };
|
||||
OrbitingObject* m_Moon{ nullptr };
|
||||
|
||||
Texture* m_topCover{ nullptr };
|
||||
|
||||
// ImGui Vars
|
||||
|
||||
BIN
Resources/moon.png
Normal file
BIN
Resources/moon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
BIN
Resources/sun.png
Normal file
BIN
Resources/sun.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Reference in New Issue
Block a user