2000-08-29 21:54:22 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
gstate.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: PRLSR
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "system\global.h"
|
|
|
|
#include "system\gstate.h"
|
|
|
|
|
2000-10-05 16:16:09 +02:00
|
|
|
#ifndef __SYSTEM_CLICKCOUNT_H__
|
|
|
|
#include "system\clickcount.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-08-29 21:54:22 +02:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
static CScene *s_currentScene;
|
|
|
|
static CScene *s_pendingScene;
|
|
|
|
|
|
|
|
int GameState::s_timeSinceLast;
|
2000-10-05 16:16:09 +02:00
|
|
|
static CClickCount s_clickCounter;
|
2000-08-29 21:54:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void GameState::initialise()
|
|
|
|
{
|
|
|
|
s_currentScene=NULL;
|
|
|
|
s_pendingScene=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void GameState::think()
|
|
|
|
{
|
|
|
|
updateTimer();
|
|
|
|
|
|
|
|
if( s_pendingScene )
|
|
|
|
{
|
|
|
|
if( !s_currentScene)
|
|
|
|
{
|
|
|
|
if( s_currentScene )
|
|
|
|
{
|
2000-09-12 01:41:29 +02:00
|
|
|
s_currentScene->shutdown();
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s_currentScene=s_pendingScene;
|
|
|
|
s_pendingScene=NULL;
|
|
|
|
|
2000-09-12 01:41:29 +02:00
|
|
|
s_currentScene->init();
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT(s_currentScene);
|
2000-09-12 01:41:29 +02:00
|
|
|
s_currentScene->think();
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void GameState::render()
|
|
|
|
{
|
|
|
|
ASSERT(s_currentScene);
|
2000-09-12 01:41:29 +02:00
|
|
|
s_currentScene->render();
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void GameState::setNextScene( CScene *_nextScene )
|
|
|
|
{
|
|
|
|
ASSERT(!s_pendingScene);
|
|
|
|
|
|
|
|
s_pendingScene=_nextScene;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
CScene * GameState::getCurrentScene()
|
|
|
|
{
|
|
|
|
return s_currentScene;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-10-05 16:16:09 +02:00
|
|
|
static int s_timeSpeed = ONE;
|
2000-08-29 21:54:22 +02:00
|
|
|
void GameState::updateTimer()
|
|
|
|
{
|
2000-10-05 16:16:09 +02:00
|
|
|
s_timeSinceLast = (s_clickCounter.timeSinceLast() * s_timeSpeed) >> 12;
|
|
|
|
|
|
|
|
if (s_timeSinceLast > 4 * 4096)
|
|
|
|
{
|
|
|
|
s_timeSinceLast = 4 * 4096;
|
|
|
|
}
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|