Potato Engine
Loading...
Searching...
No Matches
DebugInfo.cpp
Go to the documentation of this file.
1
2
5
6#include "DebugInfo.hpp"
7
8DebugInfo::DebugInfo(std::string UID) : Widget(std::move(UID)) {
9
10 TextElement* playerPosElem = AddElement<TextElement>("PlayerPosText");
11 TextElement* cameraPosElem = AddElement<TextElement>("CameraPosText");
12 TextElement* keyDisplay = AddElement<TextElement>("KeyDisplay");
13
14 playerPosElem->SetScreenPosition(Vector2(0.0,0.0));
15 cameraPosElem->SetScreenPosition(Vector2(0.0,1.0));
16 keyDisplay->SetScreenPosition(Vector2(0.0,2.0));
17
18 playerPosElem->SetVisibility(true);
19 cameraPosElem->SetVisibility(true);
20 keyDisplay->SetVisibility(true);
21
22 SetScreenSize(Vector2(30.0, 5.0));
23 SetScreenPosition(Vector2(0.0, 0.0));
24
25 SetTicking(true);
26 SetVisibility(false);
27}
28
29void DebugInfo::Tick(float dt) {
30 Widget::Tick(dt);
31
33 Vector2 playerPos = plrCtrl->GetPlayer()->GetPosition();
34 Vector2 cameraPos = plrCtrl->GetCamera()->GetPosition();
35
36 dynamic_cast<TextElement*>(GetElement("PlayerPosText"))->field = "Player position: " + playerPos.ToString();
37 dynamic_cast<TextElement*>(GetElement("CameraPosText"))->field = "Camera position: " + cameraPos.ToString();
38
39}
40
41DebugInfo::~DebugInfo() {
42
43}
Vector2 GetPosition() const
Gets position.
Definition Actor.cpp:38
virtual void Tick(float dt) override
Update tick event.
Definition DebugInfo.cpp:29
static GameInstance * get()
Gets singleton instance.
PlayerController * GetPlayerController() const
Gets player controller object.
Main managing class for the player, controlling interactions and non-local behavior.
Camera * GetCamera() const
Gets assigned Camera.
Player * GetPlayer() const
Gets assigned Player.
virtual void Tick(float dt)
Update tick event.
Definition Tickable.cpp:26
void SetScreenPosition(const Vector2 &ScreenPosition)
Sets screen position of UI.
Definition UIElement.cpp:16
void SetVisibility(bool visibility)
Sets visibility of UI.
Definition UIElement.cpp:28
UI element that can be displayed on screen.
Definition Widget.hpp:15
WidgetElement * GetElement(std::string name)
Gets specific element by name.
Definition Widget.cpp:21
Element that displays text on a widget.
Standard 2-dimensional vector.
Definition Vector2.hpp:11
std::string ToString() const
Definition Vector2.hpp:79