Jump to content

  • Log In with Google      Sign In   
  • Create Account

precious roy

Member Since 30 Oct 2007
Offline Last Active Mar 27 2016 12:49 PM

#5281083 Game Timer problems

Posted by on 13 March 2016 - 01:37 PM

Hello all,


I have been working on a small 2d rpg game, i am at the point where i need to use my game timer but it seems there is a problem with it and i can not figure out what it is. i have a fire ball that gets spawned and moves in a certain direction and continues untill outside of screen.

void FireBall::FireBall()
	//set movement
	switch (Direction)
	case AD_Up:
		Acceleration.Y -= speed; // speed = 0.05
	case AD_Down:
		Acceleration.Y += speed;
	case AD_Left:
		Acceleration.X -= speed;
	case AD_Right:
		Acceleration.X += speed;

void FireBall::Update()
	double dt = ThePrecisionDeltaTime::Instance().GetDt();
	Velocity += Acceleration * dt;
	Acceleration = 0;
	Location += Velocity * dt;

void FireBall::Draw(Camera* camera)
	Vector2F camtrans = Location - Vector2F(camera->Screen.Location());

	mFireBallSheet->Draw(animation.GetAnimationFrame(), camtrans);

and my timer: 

	m_Frequency = double(Frequency.QuadPart) / 1000.0;

double Windows_PrecisionDeltaTime::GetTicks() const
	return m_CurrentTick;

double Windows_PrecisionDeltaTime::GetDt() const
	return m_DeltaTime;

void Windows_PrecisionDeltaTime::Update()

	m_CurrentTick = double(CurrentTick.QuadPart) / m_Frequency;
	m_DeltaTime = m_CurrentTick - m_LastTick;
	m_LastTick = m_CurrentTick;

The problem is when i play the game in release or debug the fireball will fly at different speeds, also in release if i shoot them in close proximity some fireballs go faster than other fireballs when the speed should be a constant.


do any of you know what i am doing wrong here. i can record a vid if that will help illustratie the problem more.