Add velocity HUD display (Velocity: 0) in top-left corner
This commit is contained in:
parent
a1d54b01b0
commit
aa9590e2f4
@ -163,7 +163,19 @@
|
|||||||
"hover": "resources/shoot_hover.png",
|
"hover": "resources/shoot_hover.png",
|
||||||
"pressed": "resources/shoot_pressed.png"
|
"pressed": "resources/shoot_pressed.png"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"type": "TextView",
|
||||||
|
"name": "velocityText",
|
||||||
|
"x": 10,
|
||||||
|
"y": 10,
|
||||||
|
"width": 200,
|
||||||
|
"height": 40,
|
||||||
|
"text": "Velocity: 0",
|
||||||
|
"fontSize": 24,
|
||||||
|
"color": [1.0, 1.0, 1.0, 1.0],
|
||||||
|
"centered": false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1216,8 +1216,13 @@ namespace ZL
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update velocity text
|
// update velocity text
|
||||||
std::string velocityStr = "Velocity: " + std::to_string(static_cast<int>(Environment::shipState.velocity));
|
if (shipAlive && !gameOver) {
|
||||||
uiManager.setText("velocityText", velocityStr);
|
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));
|
uiManager.update(static_cast<float>(delta));
|
||||||
lastTickCount = newTickCount;
|
lastTickCount = newTickCount;
|
||||||
|
|||||||
@ -903,7 +903,6 @@ namespace ZL {
|
|||||||
bool UiManager::setText(const std::string& name, const std::string& newText) {
|
bool UiManager::setText(const std::string& name, const std::string& newText) {
|
||||||
auto tv = findTextView(name);
|
auto tv = findTextView(name);
|
||||||
if (!tv) {
|
if (!tv) {
|
||||||
std::cerr << "TextView not found: " << name << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tv->text = newText;
|
tv->text = newText;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user