mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 22:31:49 +01:00
Basic screen system
This commit is contained in:
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 };
|
||||
};
|
||||
Reference in New Issue
Block a user