Sign in to follow this  

Hud smoothing problem

This topic is 3668 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[i]);
	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[i], 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

This topic is 3668 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this