made animations extremely precise
parent
50e4c506a0
commit
5b8698af03
|
@ -10,11 +10,11 @@ using namespace std;
|
|||
int main() {
|
||||
Shooter game;
|
||||
|
||||
//game.create(1280, 720, ShooterConsts::PROJECT_NAME);
|
||||
game.create(1280, 720, ShooterConsts::PROJECT_NAME);
|
||||
//game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
|
||||
|
||||
//game.create(2048, 1152, ShooterConsts::PROJECT_NAME, true);
|
||||
game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
|
||||
//game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -21,8 +21,7 @@ private:
|
|||
return;
|
||||
}
|
||||
|
||||
_object.lock()->rotateLeft(-_object.lock()->angleLeftUpLookAt().x());
|
||||
_object.lock()->rotateLeft(_rotationValue*(progress()));
|
||||
_object.lock()->rotateLeft(_rotationValue*dprogress());
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -17,26 +17,17 @@ bool Animation::updateState() {
|
|||
// linear normalized time:
|
||||
_dtime = Time::deltaTime() / _duration;
|
||||
|
||||
if(_time + _dtime > 1.0) {
|
||||
_dtime = 1.0 - _time;
|
||||
_finished = true;
|
||||
}
|
||||
|
||||
switch (_intType) {
|
||||
case InterpolationType::Bezier:
|
||||
_progress = Interpolation::Bezier(Consts::BEZIER[0], Consts::BEZIER[1], _time);
|
||||
_dprogress = Interpolation::dBezier(Consts::BEZIER[0], Consts::BEZIER[1], _time, _dtime);
|
||||
break;
|
||||
case InterpolationType::Bouncing:
|
||||
_progress = Interpolation::Bouncing(_time);
|
||||
_dprogress = Interpolation::dBouncing(_time, _dtime);
|
||||
break;
|
||||
case InterpolationType::Linear:
|
||||
_progress = Interpolation::Linear(_time);
|
||||
_dprogress = Interpolation::dLinear(_time, _dtime);
|
||||
break;
|
||||
case InterpolationType::Cos:
|
||||
_progress = Interpolation::Cos(_time);
|
||||
_dprogress = Interpolation::dCos(_time, _dtime);
|
||||
break;
|
||||
default:
|
||||
|
@ -44,7 +35,16 @@ bool Animation::updateState() {
|
|||
"Animation::updateState: unknown interpolation type " + std::to_string(static_cast<int>(_intType))};
|
||||
}
|
||||
|
||||
if (_time + _dtime > 1.0) {
|
||||
_dtime = 1.0 - _time;
|
||||
_time = 1.0;
|
||||
_dprogress = 1.0 - _progress;
|
||||
_progress = 1.0;
|
||||
_finished = true;
|
||||
} else {
|
||||
_time += _dtime;
|
||||
_progress += _dprogress;
|
||||
}
|
||||
|
||||
if (_looped == LoopOut::Continue && _time > 0.5) {
|
||||
_time = 0.5;
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
[[nodiscard]] double dprogress() const { return _dprogress; }
|
||||
|
||||
void stop() { _finished = true; }
|
||||
|
||||
[[nodiscard]] bool isFinished() const { return _finished; }
|
||||
};
|
||||
|
||||
#endif //INC_3DZAVR_ANIMATION_H
|
||||
|
|
Loading…
Reference in New Issue