mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2026-02-04 08:09:19 +01:00
Add Text rendering and Hull / Fuel Meters
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "colors.h"
|
||||
#include "GroundTileTypeManager.h"
|
||||
#include "GridSystem/GroundTileTypeManager.h"
|
||||
#include "utils.h"
|
||||
#include "GridSystem/WorldTile.h"
|
||||
#include "Levels/World/WorldLevel.h"
|
||||
|
||||
@@ -157,6 +157,80 @@
|
||||
<ClCompile Include="Camera.cpp" />
|
||||
<ClCompile Include="Game.cpp" />
|
||||
<ClCompile Include="GameManager.cpp" />
|
||||
<ClCompile Include="GridSystem\GroundTileTypeManager.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SupportJustMyCode>true</SupportJustMyCode>
|
||||
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
|
||||
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DiagnosticsFormat>Column</DiagnosticsFormat>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<ErrorReporting>Prompt</ErrorReporting>
|
||||
<ExpandAttributedSource>false</ExpandAttributedSource>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
<EnableFuzzer>false</EnableFuzzer>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<GenerateModuleDependencies>false</GenerateModuleDependencies>
|
||||
<GenerateSourceDependencies>false</GenerateSourceDependencies>
|
||||
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
|
||||
<LanguageStandard>Default</LanguageStandard>
|
||||
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
|
||||
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
|
||||
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<ObjectFileName>x64\Debug\</ObjectFileName>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>x64\Debug\Game.pch</PrecompiledHeaderOutputFile>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
|
||||
<ShowIncludes>false</ShowIncludes>
|
||||
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<SmallerTypeCheck>false</SmallerTypeCheck>
|
||||
<SpectreMitigation>false</SpectreMitigation>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
<TrackerLogDirectory>x64\Debug\Game.tlog\</TrackerLogDirectory>
|
||||
<TranslateIncludes>false</TranslateIncludes>
|
||||
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<IntelJCCErratum>false</IntelJCCErratum>
|
||||
<BuildStlModules>false</BuildStlModules>
|
||||
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
|
||||
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
|
||||
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
|
||||
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_UNICODE;UNICODE;</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<LinkCompiled>true</LinkCompiled>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GridSystem\WorldGridManager.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
@@ -307,10 +381,83 @@
|
||||
<LinkCompiled>true</LinkCompiled>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</BrowseInformation>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GroundTileTypeManager.cpp" />
|
||||
<ClCompile Include="Gui\GuiButton.cpp" />
|
||||
<ClCompile Include="Gui\GuiElement.cpp" />
|
||||
<ClCompile Include="Gui\GuiMeter.cpp" />
|
||||
<ClCompile Include="Gui\GuiText.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SupportJustMyCode>true</SupportJustMyCode>
|
||||
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
|
||||
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DiagnosticsFormat>Column</DiagnosticsFormat>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<ErrorReporting>Prompt</ErrorReporting>
|
||||
<ExpandAttributedSource>false</ExpandAttributedSource>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
<EnableFuzzer>false</EnableFuzzer>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<GenerateModuleDependencies>false</GenerateModuleDependencies>
|
||||
<GenerateSourceDependencies>false</GenerateSourceDependencies>
|
||||
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
|
||||
<LanguageStandard>Default</LanguageStandard>
|
||||
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
|
||||
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
|
||||
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<ObjectFileName>x64\Debug\</ObjectFileName>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>x64\Debug\Game.pch</PrecompiledHeaderOutputFile>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
|
||||
<ShowIncludes>false</ShowIncludes>
|
||||
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<SmallerTypeCheck>false</SmallerTypeCheck>
|
||||
<SpectreMitigation>false</SpectreMitigation>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
<TrackerLogDirectory>x64\Debug\Game.tlog\</TrackerLogDirectory>
|
||||
<TranslateIncludes>false</TranslateIncludes>
|
||||
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<IntelJCCErratum>false</IntelJCCErratum>
|
||||
<BuildStlModules>false</BuildStlModules>
|
||||
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
|
||||
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
|
||||
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
|
||||
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_UNICODE;UNICODE;</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<LinkCompiled>true</LinkCompiled>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Gui\Screen.cpp" />
|
||||
<ClCompile Include="Gui\Screens\FuelScreen.cpp" />
|
||||
<ClCompile Include="Gui\Screens\MainScreen.cpp" />
|
||||
@@ -478,12 +625,13 @@
|
||||
<ClInclude Include="Camera.h" />
|
||||
<ClInclude Include="Game.h" />
|
||||
<ClInclude Include="GameManager.h" />
|
||||
<ClInclude Include="GridSystem\GroundTileTypeManager.h" />
|
||||
<ClInclude Include="GridSystem\WorldGridManager.h" />
|
||||
<ClInclude Include="GridSystem\WorldTile.h" />
|
||||
<ClInclude Include="GroundTileTypeManager.h" />
|
||||
<ClInclude Include="Gui\GuiButton.h" />
|
||||
<ClInclude Include="Gui\GuiElement.h" />
|
||||
<ClInclude Include="Gui\GuiMeter.h" />
|
||||
<ClInclude Include="Gui\GuiText.h" />
|
||||
<ClInclude Include="Gui\Screen.h" />
|
||||
<ClInclude Include="Gui\Screens\FuelScreen.h" />
|
||||
<ClInclude Include="Gui\Screens\MainScreen.h" />
|
||||
|
||||
26
Game/Gui/GuiText.cpp
Normal file
26
Game/Gui/GuiText.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "pch.h"
|
||||
#include "GuiText.h"
|
||||
|
||||
#include "colors.h"
|
||||
GuiText::GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color): m_Position(position), m_Text(new Text(text, fontPath, size, color)) {
|
||||
|
||||
}
|
||||
|
||||
GuiText::GuiText(): m_Position(100,100), m_Text(new Text("Undefined", "fonts/verdana.ttf", 10, Colors::WHITE)) {
|
||||
|
||||
}
|
||||
|
||||
void GuiText::Draw() const {
|
||||
m_Text->Draw(m_Position);
|
||||
}
|
||||
|
||||
void GuiText::Update(float elapsedSec) {
|
||||
}
|
||||
|
||||
void GuiText::ChangeText(const std::string& text) const {
|
||||
m_Text->ChangeText(text);
|
||||
|
||||
}
|
||||
GuiText::~GuiText() {
|
||||
delete m_Text;
|
||||
}
|
||||
20
Game/Gui/GuiText.h
Normal file
20
Game/Gui/GuiText.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "GuiElement.h"
|
||||
#include "Text.h"
|
||||
#include "Texture.h"
|
||||
|
||||
class GuiText : public GuiElement {
|
||||
public:
|
||||
GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color);
|
||||
GuiText();
|
||||
|
||||
void Draw() const override;
|
||||
void Update(float elapsedSec) override;
|
||||
|
||||
void ChangeText(const std::string& text) const;
|
||||
|
||||
~GuiText() override;
|
||||
private:
|
||||
Vector2f m_Position;
|
||||
Text* m_Text;
|
||||
};
|
||||
@@ -1,8 +1,23 @@
|
||||
#include "pch.h"
|
||||
#include "MainScreen.h"
|
||||
|
||||
#include "colors.h"
|
||||
#include "utils.h"
|
||||
#include "Gui/GuiText.h"
|
||||
MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vector2f{900.f, 500.f}, manager) {
|
||||
m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f{20, 500.f - 146 / 1.5 - 20}, Vector2f{336, 146},Vector2f{336 / 2, 146 / 1.5}, 21, manager);
|
||||
Vector2f ScreenSize = utils::GetViewport();
|
||||
Vector2f FuelFrameSize{ 336, 77 };
|
||||
Vector2f HullFrameSize{ 61, 76 };
|
||||
|
||||
m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f{HullFrameSize.x + 10, ScreenSize.y - FuelFrameSize.y }, FuelFrameSize,FuelFrameSize / 1.3, 21, manager);
|
||||
this->AddElement(m_FuelMeter);
|
||||
|
||||
m_HullMeter = new GuiMeter("gui/main/hull/hull.png", Vector2f{5, ScreenSize.y - HullFrameSize.y - 10 }, HullFrameSize, HullFrameSize, 50, manager);
|
||||
this->AddElement(m_HullMeter);
|
||||
|
||||
Vector2f DepthMeterPosition{10, ScreenSize.y - 120};
|
||||
m_DepthText = new GuiText(DepthMeterPosition, "Depth: 20", "fonts/Arial.ttf", 20, Colors::YELLOW);
|
||||
this->AddElement(m_DepthText);
|
||||
}
|
||||
MainScreen::~MainScreen() = default;
|
||||
void MainScreen::Draw() const {
|
||||
@@ -14,3 +29,10 @@ void MainScreen::Update(float elapsedSecs) {
|
||||
void MainScreen::SetFuelMeterValue(float value) const {
|
||||
m_FuelMeter->SetValue(value);
|
||||
}
|
||||
void MainScreen::SetHullMeterValue(float value) const {
|
||||
m_HullMeter->SetValue(value);
|
||||
}
|
||||
void MainScreen::SetDepth(const std::string& text) const {
|
||||
m_DepthText->ChangeText(text);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "Gui/GuiMeter.h"
|
||||
#include "Gui/GuiText.h"
|
||||
#include "Gui/Screen.h"
|
||||
|
||||
class MainScreen: public Screen {
|
||||
@@ -11,8 +12,14 @@ public:
|
||||
virtual void Update(float elapsedSecs) override;
|
||||
|
||||
void SetFuelMeterValue(float value) const;
|
||||
void SetHullMeterValue(float value) const;
|
||||
|
||||
void SetDepth(const std::string& text) const;
|
||||
|
||||
private:
|
||||
GuiMeter* m_FuelMeter;
|
||||
GuiMeter* m_HullMeter;
|
||||
|
||||
GuiText* m_DepthText;
|
||||
|
||||
};
|
||||
|
||||
@@ -6,8 +6,8 @@ Building::Building(const std::string& filePath, const Vector2f& position, Textur
|
||||
m_Texture = pTextureManager->GetTexture(filePath);
|
||||
m_Size = Vector2f(m_Texture->GetWidth(), m_Texture->GetHeight());
|
||||
}
|
||||
Building::~Building() {
|
||||
}
|
||||
Building::~Building() = default;
|
||||
|
||||
void Building::Draw() const {
|
||||
m_Texture->Draw(m_Position);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "Collision.h"
|
||||
#include "colors.h"
|
||||
#include "GroundTileTypeManager.h"
|
||||
#include "../../GridSystem/GroundTileTypeManager.h"
|
||||
#include "utils.h"
|
||||
#include "GridSystem/WorldTile.h"
|
||||
#include "Gui/Screens/ScreenManager.h"
|
||||
@@ -66,6 +66,7 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_topCover = TextureManager::GetInstance()->GetTexture("topBackground.png");
|
||||
|
||||
m_MainScreen = new MainScreen(TextureManager::GetInstance());
|
||||
|
||||
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
@@ -79,6 +80,7 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
m_MousePos = Vector2f { float(mouseX), float(mouseY) };
|
||||
m_MousePos = m_pCamera->TransformMouse(m_MousePos);
|
||||
|
||||
|
||||
// for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
// for (size_t y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
// m_gridManager.GetTileAtIndex(x, y)->m_Hightlight = false;
|
||||
@@ -133,6 +135,7 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
}
|
||||
|
||||
m_MainScreen->Update(elapsedSec);
|
||||
m_MainScreen->SetDepth(std::to_string((int)-m_Player.GetPosition().y - 50) + " ft.");
|
||||
|
||||
//Vector2f playerPos = m_player.GetPosition();
|
||||
//Vector2f newCameraPos = playerPos;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "GridSystem/WorldGridManager.h"
|
||||
#include "Gui/Screens/ScreenManager.h"
|
||||
#include "Camera.h"
|
||||
#include "Text.h"
|
||||
#include "Gui/GuiMeter.h"
|
||||
#include "Gui/Screens/MainScreen.h"
|
||||
#include "Particle/Particle.h"
|
||||
@@ -47,7 +48,7 @@ private:
|
||||
|
||||
|
||||
MainScreen* m_MainScreen{};
|
||||
|
||||
|
||||
Texture* m_topCover{ nullptr };
|
||||
|
||||
// ImGui Vars
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "colors.h"
|
||||
#include "GroundTileTypeManager.h"
|
||||
#include "GridSystem/GroundTileTypeManager.h"
|
||||
#include "utils.h"
|
||||
#include "Levels/World/WorldLevel.h"
|
||||
#include "Animations/Animation.h"
|
||||
|
||||
Reference in New Issue
Block a user