Jump to content
  • Advertisement
Sign in to follow this  

Hud smoothing problem

This topic is 3972 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi there guys i have a little problem with a hud i am trying to get running smoothly, the hud simply displays the average speed you are going , and when you are in the green that means you have hit the target of your average speed. The problem i have is that when i am on lap one it works perfectly but when you cross the line to start another lap. The hud flys to the end of the speed and then back down to where it should be . i know why it is doing this, i think it is because you carry the speed through the line but is there a way i can smooth it over so that it does not look so obvious. the hud is simply a bar that increases the section of the bitmap 'HudFraction', the green target area of the bitmap starts 3/4 in the bar. my code is below
for(i = 0; i < 3; i++)

	fAverageSpeed = LapTimesCalcAverageSpeed((float)LapTimesData->current,PlayerCar->lapDistance * pTrackData->pTracks[gCurrentRace].laplength);
	fHighSpeedTarget = LapTimeSpeedCalc(Test1Targets);
	fTopSpeed = (fHighSpeedTarget/3)*4;
	fHudFraction = (HUD_OVERLAY_WIDTH/fTopSpeed) * fAverageSpeed ;


[Edited by - Prog101 on December 4, 2007 6:32:38 AM]

Share this post

Link to post
Share on other sites
1) Don't repeat yourself. Don't repeat yourself. Don't repeat yourself.

float targetSpeed = Test1Targets[LapTimesData->lapCount];
/* here we put target speed of Test1Targets, which will be 2/3 of the bar*/
recAverageSpeed = LapTimesCalcAverageSpeed((float)LapTimesData->current,PlayerCar->lapDistance * pTrackData->pTracks[gCurrentRace].laplength);
recHighSpeed = LapTimeSpeedCalc(targetSpeed);
float topSpeed = (recHighSpeed/3)*4;
HudFraction = (HUD_OVERLAY_WIDTH/topSpeed) * recAverageSpeed ;

2) At the beginning of the lap, the "current" lap speed will approach the instantaneous speed. To avoid that, you could just add in the time and distance of the previous lap, but that will make things somewhat unresponsive. You might instead consider tracking the distance moved within the last X amount of time, as opposed to a per-lap average speed?

3) I'm very worried about what the sample code suggests about the implementation of LapTimesData. You *do* know about standard library containers, yes?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!