4
1
mirror of https://github.com/QuasarApp/Snake.git synced 2025-05-14 02:19:44 +00:00

fix movable objects

This commit is contained in:
Andrei Yankovich 2021-06-24 01:41:53 +03:00
parent b9f213b4a2
commit 8ee9e8b20b
3 changed files with 5 additions and 4 deletions

@ -29,8 +29,10 @@ void MovableObject::render(unsigned int tbfMsec) {
// recalc new currentMovable vector (applay changes)
_currentMovableVector += tempVector;
float newMovableVectorLength = std::max(_movableVector.length() - (_breakingForce * (tbfMsec / 1000.0)), 0.0);
// update movable vector
_movableVector *= 1 - (_breakingForce * (tbfMsec / 1000.0));
_movableVector = _movableVector.normalized() * newMovableVectorLength;
}

@ -57,12 +57,11 @@ public:
/**
* @brief breakingForce This method return current value of the breaking force.
* @return urrent value of the breaking force
* @note This is resistance coefficient where 0 do not change movable vector and 1 stop moving on one second.
*/
float breakingForce() const;
/**
* @brief setBreakingForce This method sets new value of the breaking force
* @brief setBreakingForce This method sets new value of the breaking force.
* @param newBreakingForce This is new value of the breaking force
*/
void setBreakingForce(float newBreakingForce);

@ -1 +1 @@
Subproject commit de7d1fad23fea1ae447c3e499845d1dfe6bd9b40
Subproject commit 46878c18cae14eed67a2b105dc993ff2d670a3bc