mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 03:41:48 +01:00
Basic screen system
This commit is contained in:
93
.idea/.idea.Motherload/.idea/workspace.xml
generated
93
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -11,34 +11,21 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/.name" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/indexLayout.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/projectSettingsUpdater.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Assets/Player/PlayerWalk.aseprite" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Animations/Animation.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Animations/Animation.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/copilot/chatSessions/blobs/version" beforeDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Gui/Button.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Gui/Button.h" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Gui/Screen.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/Game/Gui/Screen.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/PlayerWalk.aseprite" beforeDir="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$/Engine/Collision.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/Collision.cpp" 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/Game.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Game.vcxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Level.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Level.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Level.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Level.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/TextureManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/TextureManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/WorldGridManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/WorldGridManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/WorldLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/WorldLevel.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/WorldLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/WorldLevel.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/WorldTile.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/WorldTile.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/main.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/pch.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/pch.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -72,12 +59,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" />
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
@@ -95,28 +76,28 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"C++ Project.Game.executor": "Run",
|
||||
"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": "CppClangTidyOptionsId",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"C++ Project.Game.executor": "Run",
|
||||
"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": "CppClangTidyOptionsId",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Bram\\AppData\\Local\\Symbols\\src"
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Bram\\AppData\\Roaming\\JetBrains\\Rider2023.3\\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>
|
||||
@@ -191,7 +172,10 @@
|
||||
<workItem from="1711718669225" duration="530000" />
|
||||
<workItem from="1711734864498" duration="5607000" />
|
||||
<workItem from="1711819496854" duration="481000" />
|
||||
<workItem from="1711959076645" duration="941000" />
|
||||
<workItem from="1711959076645" duration="5786000" />
|
||||
<workItem from="1711987750989" duration="660000" />
|
||||
<workItem from="1711988744393" duration="1555000" />
|
||||
<workItem from="1712008689540" duration="3701000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||
<option name="closed" value="true" />
|
||||
@@ -201,7 +185,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1711648418492</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<task id="LOCAL-00002" summary="Reformat + Basic animation system General fixes">
|
||||
<option name="closed" value="true" />
|
||||
<created>1711960060059</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1711960060059</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="3" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -211,7 +203,8 @@
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||
<MESSAGE value="Rework Tile detection system" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Rework Tile detection system" />
|
||||
<MESSAGE value="Reformat + Basic animation system General fixes" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Reformat + Basic animation system General fixes" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "utils.h"
|
||||
#include "../Game/Player.h"
|
||||
#include "../Game/WorldTile.h"
|
||||
#include "../Game/GridSystem/WorldTile.h"
|
||||
|
||||
namespace Collision
|
||||
{
|
||||
|
||||
@@ -65,6 +65,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(int left, int bottom, int width, int height) : left { (float)left }, bottom { (float)bottom }, width { (float)width }, height { (float)height } {
|
||||
// }
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ 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)
|
||||
|
||||
Point2f BottomLeft() const { return Point2f{ left, bottom }; }
|
||||
|
||||
632
Engine/utils.cpp
632
Engine/utils.cpp
File diff suppressed because it is too large
Load Diff
@@ -111,4 +111,6 @@ namespace utils
|
||||
bool isMouseDown(int button);
|
||||
bool isKeyUp(int keycode);
|
||||
|
||||
Point2f GetMousePos();
|
||||
|
||||
}
|
||||
@@ -299,6 +299,8 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<LinkCompiled>true</LinkCompiled>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Gui\Button.cpp" />
|
||||
<ClCompile Include="Gui\Screen.cpp" />
|
||||
<ClCompile Include="Level.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
@@ -458,6 +460,8 @@
|
||||
<ClInclude Include="Game.h"/>
|
||||
<ClInclude Include="GridSystem\WorldGridManager.h"/>
|
||||
<ClInclude Include="GridSystem\WorldTile.h"/>
|
||||
<ClInclude Include="Gui\Button.h" />
|
||||
<ClInclude Include="Gui\Screen.h" />
|
||||
<ClInclude Include="Level.h"/>
|
||||
<ClInclude Include="pch.h"/>
|
||||
<ClInclude Include="Player.h"/>
|
||||
|
||||
1
Game/Gui/Button.cpp
Normal file
1
Game/Gui/Button.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "Button.h"
|
||||
19
Game/Gui/Button.h
Normal file
19
Game/Gui/Button.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "Texture.h"
|
||||
|
||||
class Button
|
||||
{
|
||||
public:
|
||||
Button() = default;
|
||||
Button(const std::string& filePath, Point2f pos, Point2f size);
|
||||
void Draw() const;
|
||||
void Update(float elapsedSec);
|
||||
|
||||
private:
|
||||
Texture* m_Texture{ nullptr };
|
||||
Point2f m_Position;
|
||||
Point2f m_Size;
|
||||
|
||||
bool m_IsHovered{ false };
|
||||
bool m_IsPressed{ false };
|
||||
};
|
||||
14
Game/Gui/Screen.cpp
Normal file
14
Game/Gui/Screen.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "Screen.h"
|
||||
Screen::Screen(const std::string& filePath, Point2f pos, Point2f size,TextureManager* manager): m_Position(pos), m_Size(size)
|
||||
{
|
||||
m_Background = manager->GetTexture(filePath);
|
||||
}
|
||||
Screen::~Screen() {
|
||||
}
|
||||
void Screen::Update(float elapsedSecs) {
|
||||
}
|
||||
void Screen::Draw() const {
|
||||
Rectf dest = Rectf(m_Position, m_Size);
|
||||
Rectf src = Rectf(0,0, m_Background->GetWidth(), m_Background->GetHeight());
|
||||
m_Background->Draw(dest, src, false);
|
||||
}
|
||||
26
Game/Gui/Screen.h
Normal file
26
Game/Gui/Screen.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "structs.h"
|
||||
#include "Texture.h"
|
||||
#include "../TextureManager.h"
|
||||
|
||||
class Screen
|
||||
{
|
||||
public:
|
||||
Screen() = default;
|
||||
Screen(const std::string& filePath, Point2f pos, Point2f size, TextureManager* manager);
|
||||
|
||||
~Screen();
|
||||
|
||||
void setActive(bool active) { m_Active = active; }
|
||||
void toggleActive() { m_Active = !m_Active; }
|
||||
|
||||
void Update(float elapsedSecs);
|
||||
void Draw() const;
|
||||
private:
|
||||
Point2f m_Position;
|
||||
Point2f m_Size;
|
||||
|
||||
Texture* m_Background{ nullptr };
|
||||
|
||||
bool m_Active{ false };
|
||||
};
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "utils.h"
|
||||
#include "WorldLevel.h"
|
||||
#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 }) {
|
||||
m_ContactMap[Collision::CollisionDirection::Top] = nullptr;
|
||||
@@ -39,7 +40,7 @@ void Player::ProcessImGui() {
|
||||
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::Text("is Grounded: %s", m_Grounded ? "true" : "false");
|
||||
ImGui::Text("Did just dig right: %s", m_DidJustDigRight ? "true" : "false");
|
||||
bool test = !utils::isKeyDown(SDL_SCANCODE_H);
|
||||
bool test = !utils::isKeyPressed(SDL_SCANCODE_H);
|
||||
ImGui::Text("Is Key Up H: %s", test ? "true" : "false");
|
||||
ImGui::Checkbox("Draw Collision Rect", &m_DrawCollisionRect);
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
#include "Collision.h"
|
||||
#include "colors.h"
|
||||
#include "utils.h"
|
||||
#include "GridSystem/WorldTile.h"
|
||||
|
||||
|
||||
class GroundTileType;
|
||||
WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_gridManager(WorldGridManager()),
|
||||
m_player(Player { Point2f { 0, 100 }, TextureManager::GetInstance() }),
|
||||
@@ -33,7 +35,7 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
//AIR
|
||||
break;
|
||||
default:
|
||||
std::cout << "??" << std::endl;
|
||||
std::cout << "??" << '\n';
|
||||
}
|
||||
|
||||
m_gridManager.SetTileAtIndex(x, y, new WorldTile { pos, type, TextureManager::GetInstance() });
|
||||
@@ -42,6 +44,8 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
for (size_t x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
m_gridManager.GetTileAtIndex(x, 0)->SetTileType(Tiles::AIR);
|
||||
}
|
||||
Point2f screenCenterPos = Point2f { m_viewport.width / 2 - 492 / 2, m_viewport.height / 2 - 396 / 2 };
|
||||
m_screen = Screen{ "gui/fuel/background.png", screenCenterPos, Point2f { 492, 396 }, TextureManager::GetInstance() };
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
//delete m_pTextTexture;
|
||||
@@ -117,6 +121,10 @@ void WorldLevel::Draw() const {
|
||||
|
||||
m_player.Draw();
|
||||
m_pCamera->EndRendering();
|
||||
|
||||
utils::FillRect(utils::GetMousePos(), 10, 10);
|
||||
|
||||
m_screen.Draw();
|
||||
}
|
||||
void WorldLevel::MouseMove(const Point2f& mousePos) {
|
||||
m_mousePos = mousePos;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "Level.h"
|
||||
#include "Player.h"
|
||||
#include "utils.h"
|
||||
#include "WorldLevel.h"
|
||||
#include "GridSystem/WorldGridManager.h"
|
||||
#include "Gui/Screen.h"
|
||||
|
||||
|
||||
class WorldLevel : public Level
|
||||
@@ -35,6 +35,8 @@ private:
|
||||
|
||||
Rectf m_viewport;
|
||||
|
||||
Screen m_screen;
|
||||
|
||||
// ImGui Vars
|
||||
bool m_ShowTextureManagerWindow { false };
|
||||
bool m_ShowCameraWindow { false };
|
||||
|
||||
@@ -11,7 +11,7 @@ int SDL_main(int argv, char** args) {
|
||||
|
||||
StartHeapControl();
|
||||
|
||||
auto pGame { new Game { Window { "Motherload - Verhulst, Bram - 1DAEGD16E", 846.f, 500.f } } };
|
||||
auto pGame { new Game { Window { "Motherload - Verhulst, Bram - 1DAEGD16E", 900.f, 500.f } } };
|
||||
pGame->Run();
|
||||
delete pGame;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user