forked from mirrors/kolyah35-minecraft-pe-0.6.1
the whole game
This commit is contained in:
parent
816e9060b4
commit
f0617a5d22
2069 changed files with 581500 additions and 0 deletions
37
src/util/SmoothFloat.h
Executable file
37
src/util/SmoothFloat.h
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef UTIL__SmoothFloat_H__
|
||||
#define UTIL__SmoothFloat_H__
|
||||
|
||||
//package util;
|
||||
|
||||
class SmoothFloat
|
||||
{
|
||||
float targetValue;
|
||||
float remainingValue;
|
||||
float lastAmount;
|
||||
|
||||
public:
|
||||
SmoothFloat()
|
||||
: targetValue(0),
|
||||
remainingValue(0),
|
||||
lastAmount(0)
|
||||
{}
|
||||
|
||||
float getNewDeltaValue(float deltaValue, float accelerationAmount) {
|
||||
targetValue += deltaValue;
|
||||
|
||||
deltaValue = (targetValue - remainingValue) * accelerationAmount;
|
||||
lastAmount = lastAmount + (deltaValue - lastAmount) * .5f;
|
||||
if ((deltaValue > 0 && deltaValue > lastAmount) || (deltaValue < 0 && deltaValue < lastAmount)) {
|
||||
deltaValue = lastAmount;
|
||||
}
|
||||
remainingValue += deltaValue;
|
||||
|
||||
return deltaValue;
|
||||
}
|
||||
|
||||
float getTargetValue() {
|
||||
return targetValue;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*UTIL__SmoothFloat_H__*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue