Merge pull request #1211 from suve/limit-game-speeds
Add a minimum & maximum game speed limit1008-fix
commit
d57c45cbb2
|
@ -60,6 +60,7 @@
|
||||||
#include "level/parser/parser.h"
|
#include "level/parser/parser.h"
|
||||||
|
|
||||||
#include "math/const.h"
|
#include "math/const.h"
|
||||||
|
#include "math/func.h"
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
@ -119,6 +120,10 @@
|
||||||
const float UNIT = 4.0f; // default for g_unit
|
const float UNIT = 4.0f; // default for g_unit
|
||||||
float g_unit; // conversion factor
|
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()
|
// 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_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
|
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();
|
return m_ui->UpdateChapterPassed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Changes game speed
|
//! Changes game speed
|
||||||
void CRobotMain::SetSpeed(float speed)
|
void CRobotMain::SetSpeed(float speed)
|
||||||
{
|
{
|
||||||
|
speed = Math::Clamp(speed, MIN_SPEED, MAX_SPEED);
|
||||||
|
|
||||||
m_app->SetSimulationSpeed(speed);
|
m_app->SetSimulationSpeed(speed);
|
||||||
UpdateSpeedLabel();
|
UpdateSpeedLabel();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue