Posted: 29th Mar 2024 22:20
Hello everyone, could you tell me how to make the progress bar smooth? I am creating a fuel consumption band, but it changes in 1 second

The essence of the code is that when I press the gas pedal, the strip should decrease little by little

[video=youtube]https://youtu.be/W_TE8CHaJQI[/video]

+ Code Snippet
// Displaying the fuel strip on the screen
Function FuelBarControl()
	FuelPercent = Current_fuel / 300 * 100 // 300 this is the volume of a full tank
	DrawBox( GetScreenBoundsLeft()+51, 53, GetScreenBoundsLeft()+FuelPercent+51, 72, MakeColor(0,128,0), MakeColor(0,128,0), MakeColor(0,128,0), MakeColor(0,128,0), 1 )
EndFunction

// Fuel consumption function
Function FuelFlow()
	Current_fuel = Current_fuel - 0.7
EndFunction
Posted: 30th Mar 2024 0:22
Maybe...

Could you just make Current_fuel a float? Current_fuel#
FuelPercent is an integer and should move slowly. And play with the 0.01 value a bit.

+ Code Snippet
// Displaying the fuel strip on the screen
Function FuelBarControl()
	FuelPercent = Current_fuel#
	DrawBox( GetScreenBoundsLeft()+51, 53, GetScreenBoundsLeft()+FuelPercent+51, 72, MakeColor(0,128,0), MakeColor(0,128,0), MakeColor(0,128,0), MakeColor(0,128,0), 1 )
EndFunction

// Fuel consumption function
Function FuelFlow()
	Current_fuel# = Current_fuel# - 0.01
EndFunction
Posted: 30th Mar 2024 16:17
Azamaticon, Here's a simple implementation example. Next on my own. You can improve, refine, the main thing is to understand the main essence.