This commit is contained in:
Bram Verhulst
2024-06-04 14:38:46 +02:00
parent e1165fdcb4
commit d7389411f5
9 changed files with 68 additions and 37 deletions

View File

@@ -14,7 +14,7 @@
Rectf Game::VIEWPORT {};
Game::Game(const Window& window)
: BaseGame { window }, m_Camera(Camera()), m_WorldLevel(WorldLevel(&m_Camera, GetViewPort())),
: BaseGame { window }, m_Camera(Camera()), m_WorldLevel(&m_Camera, GetViewPort()),
m_MainMenuLevel(MainMenuLevel(&m_Camera)), m_pCurrentLevel(&m_WorldLevel) {
Initialize();
Game::VIEWPORT = GetViewPort(); //TODO: See if this can be removed

View File

@@ -110,15 +110,15 @@ void WorldTile::Draw() {
// return;
// }
// else {
this->DrawSide(TileDirection::TopLeft);
this->DrawSide(TileDirection::TopRight);
this->DrawSide(TileDirection::BottomLeft);
this->DrawSide(TileDirection::BottomRight);
this->DrawSide(TileDirection::TopLeft);
this->DrawSide(TileDirection::TopRight);
this->DrawSide(TileDirection::BottomLeft);
this->DrawSide(TileDirection::BottomRight);
this->DrawSide(TileDirection::TopMiddle);
this->DrawSide(TileDirection::BottomMiddle);
this->DrawSide(TileDirection::MiddleLeft);
this->DrawSide(TileDirection::MiddleRight);
this->DrawSide(TileDirection::TopMiddle);
this->DrawSide(TileDirection::BottomMiddle);
this->DrawSide(TileDirection::MiddleLeft);
this->DrawSide(TileDirection::MiddleRight);
// }
break;
}

View File

@@ -2,9 +2,10 @@
#include "Screen.h"
Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
if(!filePath.empty()) {
if (!filePath.empty()) {
m_Background = manager->GetTexture(filePath);
} else {
}
else {
m_Background = nullptr;
}
}
@@ -13,13 +14,16 @@ Screen::~Screen() {
delete b;
}
}
void Screen::AddElement(GuiElement* element) {
m_Elements.push_back(element);
}
void Screen::Update(float elapsedSecs) {
for (GuiElement* b : m_Elements) {
b->Update(elapsedSecs);
}
}
void Screen::Draw() const {
if(m_Background != nullptr) { //Incase there is no background
if (m_Background != nullptr) { //Incase there is no background
Rectf dest = Rectf(m_Position, m_Size);
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());
m_Background->Draw(dest, src, false);

View File

@@ -14,7 +14,7 @@ public:
virtual ~Screen();
void AddElement(GuiElement* element) { m_Elements.push_back(element); }
void AddElement(GuiElement* element);
virtual void Update(float elapsedSecs);
virtual void Draw() const;

View File

@@ -18,7 +18,7 @@
class GroundTileType;
WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
m_GridManager(WorldGridManager()),
m_Player(Player { Vector2f { 0, 100 }, TextureManager::GetInstance() }),
m_Player(Vector2f { 0, 100 }, TextureManager::GetInstance()),
m_MousePos { 0, 0 },
m_Viewport(viewport),
m_ScreenManager(ScreenManager::GetInstance()) {

View File

@@ -45,9 +45,6 @@ Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(P
m_currentAnimation = m_walkAnimation;
}
Player::Player(Player&& other) {
}
Player::~Player() {
delete m_walkAnimation;

View File

@@ -35,7 +35,7 @@ class Player
public:
explicit Player(const Vector2f& Position, TextureManager* pTextureManager);
Player( const Player& other ) = default;
Player(Player&& other);
Player(Player&& other) = delete;
Player& operator=(const Player& other) = delete;
Player& operator=(Player&& other) = delete;