# 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.

## 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 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?

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009381
• ### Who's Online (See full list)

There are no registered users currently online

×