Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualmolehill mountaineer

Posted 12 December 2012 - 03:45 PM

Try passing "p_speedFactor" as a float around, possible loss of information.


//time difference between this frame and the previous frame in seconds
m_deltaTime = (m_currTime - m_prevTime) * m_secondsPerCount;

Whats m_secondsPerCount ? and why is it there?

float dt = 0.0;
float currentTime = hires_time_in_seconds();
float lastTime;
while ( !quit )
{
dt = hires_time_in_seconds() - currentTime;
currentTime = hires_time_in_seconds();

//game related stuff
}

Read the article i posted, it will help allot fixing this problem.
You should google for , float precision, double precision, and converting then around


Hello baneTrapper, sorry it took so long to reply.
m_secondsPerCount is a number used to convert the value to seconds. You can see it being initialized in the constructor for timer.

EDIT: I see that I'm confusing the meaning of deltaTime (I'm using frank luna's book and the article you provided - frameTime in the article is deltaTime in the book). I will correct this tonight and let you know if it fixed things.


EDIT2: the problem is resolved, after reading that article again I came to the conclusion that I wasn't "consuming" my frameTime (that is, I thought that deltaTime was equal to dt if you follow gaffer's example). Thanks for the help

#2molehill mountaineer

Posted 12 December 2012 - 12:05 PM

Try passing "p_speedFactor" as a float around, possible loss of information.


//time difference between this frame and the previous frame in seconds
m_deltaTime = (m_currTime - m_prevTime) * m_secondsPerCount;

Whats m_secondsPerCount ? and why is it there?

float dt = 0.0;
float currentTime = hires_time_in_seconds();
float lastTime;
while ( !quit )
{
dt = hires_time_in_seconds() - currentTime;
currentTime = hires_time_in_seconds();

//game related stuff
}

Read the article i posted, it will help allot fixing this problem.
You should google for , float precision, double precision, and converting then around


Hello baneTrapper, sorry it took so long to reply.
m_secondsPerCount is a number used to convert the value to seconds. You can see it being initialized in the constructor for timer.

EDIT: I see that I'm confusing the meaning of deltaTime (I'm using frank luna's book and the article you provided - frameTime in the article is deltaTime in the book). I will correct this tonight and let you know if it fixed things.

#1molehill mountaineer

Posted 12 December 2012 - 07:12 AM

Try passing "p_speedFactor" as a float around, possible loss of information.


//time difference between this frame and the previous frame in seconds
m_deltaTime = (m_currTime - m_prevTime) * m_secondsPerCount;

Whats m_secondsPerCount ? and why is it there?

float dt = 0.0;
float currentTime = hires_time_in_seconds();
float lastTime;
while ( !quit )
{
dt = hires_time_in_seconds() - currentTime;
currentTime = hires_time_in_seconds();

//game related stuff
}

Read the article i posted, it will help allot fixing this problem.
You should google for , float precision, double precision, and converting then around


Hello baneTrapper, sorry it took so long to reply.
m_secondsPerCount is a number used to convert the value to seconds. You can see it being initialized in the constructor for timer.

I read the article you provided but it didn't really do anything different than what I'm doing - apart from the integration (which I assume doesn't apply for me since the objects move at constant speed). What I'm trying to do is more like the timer in this code: http://www.aaroncox.net/tutorials/2dtutorials/sdltimer.html

PARTNERS