diff --git a/Source.cpp b/Source.cpp index 7a9784a..372c41c 100644 --- a/Source.cpp +++ b/Source.cpp @@ -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; } \ No newline at end of file diff --git a/engine/animation/ARotateLeft.h b/engine/animation/ARotateLeft.h index ccaa6ab..fb0f334 100644 --- a/engine/animation/ARotateLeft.h +++ b/engine/animation/ARotateLeft.h @@ -21,8 +21,7 @@ private: return; } - _object.lock()->rotateLeft(-_object.lock()->angleLeftUpLookAt().x()); - _object.lock()->rotateLeft(_rotationValue*(progress())); + _object.lock()->rotateLeft(_rotationValue*dprogress()); } public: diff --git a/engine/animation/Animation.cpp b/engine/animation/Animation.cpp index 8e125ce..d677d64 100644 --- a/engine/animation/Animation.cpp +++ b/engine/animation/Animation.cpp @@ -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(_intType))}; } - _time += _dtime; + 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; diff --git a/engine/animation/Animation.h b/engine/animation/Animation.h index 0c99bd1..3e8304c 100644 --- a/engine/animation/Animation.h +++ b/engine/animation/Animation.h @@ -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