Implemented game speed changing by pressing - or + to e.g. ease testing.

svn-id: r33689
This commit is contained in:
Kari Salminen 2008-08-07 21:46:56 +00:00
parent da84a54694
commit 092d7224b9
4 changed files with 26 additions and 6 deletions

View File

@ -105,8 +105,22 @@ int CineEngine::go() {
return 0;
}
int CineEngine::getTimerDelay() const {
return (10923000 * _timerDelayMultiplier) / 1193180;
}
/*! \brief Modify game speed
* \param speedChange Negative values slow game down, positive values speed it up, zero does nothing
* \return Timer delay multiplier's value after the game speed change
*/
int CineEngine::modifyGameSpeed(int speedChange) {
// If we want more speed we decrement the timer delay multiplier and vice versa.
_timerDelayMultiplier = CLIP(_timerDelayMultiplier - speedChange, 1, 50);
return _timerDelayMultiplier;
}
void CineEngine::initialize() {
_timerDelayMultiplier = 12; // Set default speed
setupOpcodes();
initLanguage(g_cine->getLanguage());

View File

@ -86,6 +86,8 @@ public:
bool loadSaveDirectory(void);
void makeSystemMenu(void);
int modifyGameSpeed(int speedChange);
int getTimerDelay() const;
const CINEGameDescription *_gameDescription;
Common::File _partFileHandle;
@ -109,6 +111,7 @@ private:
void readVolCnf();
bool _preLoad;
int _timerDelayMultiplier;
};
extern CineEngine *g_cine;

View File

@ -125,6 +125,14 @@ static void processEvent(Common::Event &event) {
g_cine->makeSystemMenu();
}
break;
case Common::KEYCODE_MINUS:
case Common::KEYCODE_KP_MINUS:
g_cine->modifyGameSpeed(-1); // Slower
break;
case Common::KEYCODE_PLUS:
case Common::KEYCODE_KP_PLUS:
g_cine->modifyGameSpeed(+1); // Faster
break;
default:
lastKeyStroke = event.kbd.keycode;
break;
@ -138,7 +146,7 @@ static void processEvent(Common::Event &event) {
void manageEvents() {
Common::EventManager *eventMan = g_system->getEventManager();
uint32 nextFrame = g_system->getMillis() + kGameTimerDelay * kGameSpeed;
uint32 nextFrame = g_system->getMillis() + g_cine->getTimerDelay();
do {
Common::Event event;
while (eventMan->pollEvent(event)) {

View File

@ -28,11 +28,6 @@
namespace Cine {
enum {
kGameTimerDelay = 1000 / (1193180 / 10923),
kGameSpeed = 12
};
void mainLoop(int bootScriptIdx);
void manageEvents();