Quote: "And can you recommend me a tut for this 'timer based movement'?"
Not off the top of my head but I know there are backdated newsletters with references to it and I'm sure some focused googling would get you started.
I'll post some timer code I have handy and see if that sparks your imagination a bit
It's one of those thing where at first its like "this stinks" until you start using it and see how much it can "smooth" things.
Well... basically timer code works by tracking the amount of time elapsed per game loop, or "since last time you checked" and using this "Time Elapsed" value in such a way you're not thinking "move this much: 0.4 " your thinking "Move this much per milli second: 0.004" or something. Same kinda principle can be used for both MOVING OBJECTS via move statements or controlling turn speeds. Once you get the hang of it - it wouldn't surprise me if you have timing code all over the place! LOL
A Header File *.h
//---------------------------------------------------------------------
class JGC_CLOCK{
//---------------------------------------------------------------------
public:
int Time;
int TimePrev;
int TimeElapsed;
void Update(void);
JGC_CLOCK();
~JGC_CLOCK();
};
//---------------------------------------------------------------------
The *.cpp file
//============================================================================
// begin JGC_CLOCK
//============================================================================
//----------------------------------------------------------------------------
JGC_CLOCK::JGC_CLOCK(){
//----------------------------------------------------------------------------
Update();
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
JGC_CLOCK::~JGC_CLOCK(){
//----------------------------------------------------------------------------
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_CLOCK::Update(void){
//----------------------------------------------------------------------------
this->TimePrev = this->Time;
this->Time = dbTimer();
this->TimeElapsed = this->Time - this->TimePrev;
};
//----------------------------------------------------------------------------
//============================================================================
// end JGC_CLOCK
//============================================================================
Pseudo Code Sample
JFC_CLOCK *Clock=new JFC_CLOCK();
float fAmountToTurnPerMilli=0.001f;
float fCalculatedAmountToTurn=0.0f;
do{
Clock->Update();
fCalculatedAmountToTurn = Clock->TimeElapsed * fAmountToTurnPerMilli;
cameraAngleX = dbWrapValue(dbCameraAngleX() + dbMouseMoveY() * fCalculatedAmountToTurn);
cameraAngleY = dbWrapValue(dbCameraAngleY() + dbMouseMoveX() * fCalculatedAmountToTurn);
dbXRotateCamera(cameraAngleX);
dbYRotateCamera(cameraAngleY);
}while(WorldTurns);
That is just Pseudo - not tested - values you'll have to play with to get YOUR timing right - but I'm hoping it gets the basic idea across!
Let me know how you make out!
Jason