Add velocity HUD display (Velocity: 0) in top-left corner
This commit is contained in:
1 parent
a1d54b01b0
commit
aa9590e2f4
3 files changed
+20
-4
No files matched your search
+7
-2
@@ -1216,8 +1216,13 @@ namespace ZL
|
||||
}
|
||||
|
||||
// update velocity text
|
||||
std::string velocityStr = "Velocity: " + std::to_string(static_cast<int>(Environment::shipState.velocity));
|
||||
uiManager.setText("velocityText", velocityStr);
|
||||
if (shipAlive && !gameOver) {
|
||||
auto velocityTv = uiManager.findTextView("velocityText");
|
||||
if (velocityTv) {
|
||||
std::string velocityStr = "Velocity: " + std::to_string(static_cast<int>(Environment::shipState.velocity));
|
||||
uiManager.setText("velocityText", velocityStr);
|
||||
}
|
||||
}
|
||||
|
||||
uiManager.update(static_cast<float>(delta));
|
||||
lastTickCount = newTickCount;
|
||||
|
||||
@@ -903,7 +903,6 @@ namespace ZL {
|
||||
bool UiManager::setText(const std::string& name, const std::string& newText) {
|
||||
auto tv = findTextView(name);
|
||||
if (!tv) {
|
||||
std::cerr << "TextView not found: " << name << std::endl;
|
||||
return false;
|
||||
}
|
||||
tv->text = newText;
|
||||
|
||||
Reference in new issue
Block a user