From 50e4c506a0fe70332056fbd9d52305a26d00c831 Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Mon, 1 Nov 2021 23:40:05 +0700 Subject: [PATCH] made animations extremely precise --- Source.cpp | 4 ++-- engine/animation/ARotateLeft.h | 3 ++- engine/animation/Animation.cpp | 17 ++++++----------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Source.cpp b/Source.cpp index 372c41c..7a9784a 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 a0a6297..ccaa6ab 100644 --- a/engine/animation/ARotateLeft.h +++ b/engine/animation/ARotateLeft.h @@ -21,7 +21,8 @@ private: return; } - _object.lock()->rotateLeft(_rotationValue * dprogress()); + _object.lock()->rotateLeft(-_object.lock()->angleLeftUpLookAt().x()); + _object.lock()->rotateLeft(_rotationValue*(progress())); } public: diff --git a/engine/animation/Animation.cpp b/engine/animation/Animation.cpp index 3d035b8..8e125ce 100644 --- a/engine/animation/Animation.cpp +++ b/engine/animation/Animation.cpp @@ -17,6 +17,11 @@ 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); @@ -39,17 +44,7 @@ bool Animation::updateState() { "Animation::updateState: unknown interpolation type " + std::to_string(static_cast(_intType))}; } - if(_time + _dtime < 1.0) { - _time += _dtime; - } else { - _dtime = 1.0 - _time; - _time = 1.0; - _dprogress = 1 - _progress; - _progress = 1.0; - update(); - _finished = true; - return false; - } + _time += _dtime; if (_looped == LoopOut::Continue && _time > 0.5) { _time = 0.5;