I'm currently in the process of making a ZScript HUD, however, I can't understand how DynamicValueInterpolator works at all.
Any help would be appreciated.
How does DynamicValueInterpolator work?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Re: How does DynamicValueInterpolator work?
First declare an object of it as a member variable:
Then it must be initialized:
Then, its value needs to be constantly updated:
Finally, you can now make use of it in your code:
Code: Select all
Class MyStatusBar : BaseStatusBar
{
DynamicValueInterpolator DVIa;
DynamicValueInterpolator DVIb;
...
}
Code: Select all
Override void Init()
{
Super.Init();
DVIa = DynamicValueInterpolator.Create(0, .25, 1, 8); // Parameters: starting value, change factor, min change per update, max change per update
...
}
Code: Select all
Override void Tick()
{
Super.Tick();
DVIa.Update(CPlayer.health); // Player health variable inside brackets, as an example
}
Code: Select all
protected void DrawFullScreenStuff(double TicFrac)
{
...
DrawBar("HBARA0", "HBARY0", DVIa.GetValue(), 100, (15,1021), 0, 0); // Note the GetValue() call
}
Re: How does DynamicValueInterpolator work?
Wow, this actually helped out a lot!
Thanks for your help, it is much appreciated.
Thanks for your help, it is much appreciated.