I have created a score bar with two objects:
Score_Idle
Score_Fill, where the height starts at 0, and goes up if I get points.
I am looking for a way to limit the growth of Score_Fill, so that it does never exceed the idle object. The ideal case would be normal growth at the start, and slowing down when in the region of the top.
Anyone got ideas? Because I’m getting tunnel vision, and just trying the same things over and over^^
Could you be a bit more specific? Why the growth speed should slow down? (maybe an aesthetic detail?)
The score bar size depends of the score you have, but they growth in different speeds? If so I think a maximum score is needed
Ok, I don’t want to post just some question (your post is some days ago) , so I’ll assume:
A variable “score”
A variable “max_score”
A Score_Idle and a Score_Fill of same size
To slow down the growth speed, a nice and easy way is to use a quadratic function (or any polynomial function of degree > 1), check this:
Here, the abscissa axis is the score factor = “score”/“max_score”, so it’s in the range [0,1]. And the ordinate axis is the sprite scale, of course in the range [0,1].
So, basically, all this theory can be summarized in just one action:
Do = -pow(Variable(score)/Variable(max_score), 2) + 2*Variable(score)/Variable(max_score) to the scale of Score_Fill
You can set any math function to get the curve you want, but this is the simplest one. For example, I’ve adjusted this function (5x/(4x +1)) manually to get a sharper curve:
Do = (5*Variable(score)/Variable(max_score)) / (4*Variable(score)/Variable(max_score) + 1) to the scale of Score_Fill
You can test both curves in this example, just de/activate the final events: ScaleSpeed.zip (2.14 KB)
I would use an exponential to have a nice growth at the start decreasing at the end. With this, the score will never be the maximum possible score but will get closer and closer.
Yes, it is purely aesthetic detail, as I don’t want the score bar to expand beyond the background image, as it will grow into the areas of the game it should not.
As for now, I was using the following function:
Variable(Score)/(100*log(Variable(Objective)))
which kinda works, but still would exceed if the results of the game are very good^^ I will try your suggestions, and will keep you informed