Potato Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
DebugInfo.cpp
Go to the documentation of this file.
1
2
3
#include "
Game/Control/GameInstance.hpp
"
4
#include "
Game/UI/Widgets/TextElement.hpp
"
5
6
#include "
DebugInfo.hpp
"
7
8
DebugInfo::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
29
void
DebugInfo::Tick
(
float
dt) {
30
Widget::Tick
(dt);
31
32
PlayerController
* plrCtrl =
GameInstance::get
()->
GetPlayerController
();
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
41
DebugInfo::~DebugInfo() {
42
43
}
DebugInfo.hpp
GameInstance.hpp
TextElement.hpp
Actor::GetPosition
Vector2 GetPosition() const
Gets position.
Definition
Actor.cpp:38
DebugInfo::Tick
virtual void Tick(float dt) override
Update tick event.
Definition
DebugInfo.cpp:29
GameInstance::get
static GameInstance * get()
Gets singleton instance.
Definition
GameInstance.cpp:8
GameInstance::GetPlayerController
PlayerController * GetPlayerController() const
Gets player controller object.
Definition
GameInstance.cpp:49
PlayerController
Main managing class for the player, controlling interactions and non-local behavior.
Definition
PlayerController.hpp:13
PlayerController::GetCamera
Camera * GetCamera() const
Gets assigned Camera.
Definition
PlayerController.cpp:68
PlayerController::GetPlayer
Player * GetPlayer() const
Gets assigned Player.
Definition
PlayerController.cpp:67
Tickable::Tick
virtual void Tick(float dt)
Update tick event.
Definition
Tickable.cpp:26
UIElement::SetScreenPosition
void SetScreenPosition(const Vector2 &ScreenPosition)
Sets screen position of UI.
Definition
UIElement.cpp:16
UIElement::SetVisibility
void SetVisibility(bool visibility)
Sets visibility of UI.
Definition
UIElement.cpp:28
Widget
UI element that can be displayed on screen.
Definition
Widget.hpp:15
Widget::GetElement
WidgetElement * GetElement(std::string name)
Gets specific element by name.
Definition
Widget.cpp:21
TextElement
Element that displays text on a widget.
Definition
TextElement.hpp:10
Vector2
Standard 2-dimensional vector.
Definition
Vector2.hpp:11
Vector2::ToString
std::string ToString() const
Definition
Vector2.hpp:79
Game
UI
Widgets
Objects
DebugInfo.cpp
Generated by
1.17.0