Merge pull request #1211 from suve/limit-game-speeds

Add a minimum & maximum game speed limit
1008-fix
Mateusz Przybył 2018-12-22 15:49:53 +01:00 committed by GitHub
commit d57c45cbb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -60,6 +60,7 @@
#include "level/parser/parser.h"
#include "math/const.h"
#include "math/func.h"
#include "math/geometry.h"
#include "object/object.h"
@ -119,6 +120,10 @@
const float UNIT = 4.0f; // default for g_unit
float g_unit; // conversion factor
// Min/max values for the game speed.
const float MIN_SPEED = 1/8.0f;
const float MAX_SPEED = 256.0f;
// Reference colors used when recoloring textures, see ChangeColor()
const Gfx::Color COLOR_REF_BOT = Gfx::Color( 10.0f/256.0f, 166.0f/256.0f, 254.0f/256.0f); // blue
const Gfx::Color COLOR_REF_ALIEN = Gfx::Color(135.0f/256.0f, 170.0f/256.0f, 13.0f/256.0f); // green
@ -5358,10 +5363,11 @@ void CRobotMain::UpdateChapterPassed()
return m_ui->UpdateChapterPassed();
}
//! Changes game speed
void CRobotMain::SetSpeed(float speed)
{
speed = Math::Clamp(speed, MIN_SPEED, MAX_SPEED);
m_app->SetSimulationSpeed(speed);
UpdateSpeedLabel();
}