Make a update_percent function for meter.
This commit is contained in:
parent
1950f45f46
commit
c390ca5616
3 changed files with 8 additions and 2 deletions
|
|
@ -116,12 +116,17 @@ namespace guecs {
|
|||
$cell_w = cell.w;
|
||||
$cell_h = cell.h;
|
||||
bar.init(cell);
|
||||
update_percent(percent);
|
||||
}
|
||||
|
||||
void Meter::render(sf::RenderTarget& window, sf::Shader *shader_ptr) {
|
||||
bar.render(window, shader_ptr);
|
||||
}
|
||||
|
||||
void Meter::update_percent(float pct) {
|
||||
percent = pct;
|
||||
float level = std::clamp(percent, 0.0f, 1.0f) * float($cell_w);
|
||||
bar.shape->setSize({std::max(level, 0.0f) - padding * 2, float($cell_h) - padding * 2});
|
||||
bar.render(window, shader_ptr);
|
||||
}
|
||||
|
||||
void Sound::play(bool hover) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue