diff options
author | Bertram <bertram@cegetel.net> | 2010-02-01 11:49:11 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2010-02-01 11:49:11 +0100 |
commit | 7e2a54bedefc6b5e2b34c9dafccb8322f46266e7 (patch) | |
tree | 8a016c196e36f94ac7454e2300226461e71305c8 /src/being.cpp | |
parent | 3fe06a98c0af45d7fccce99f39f402485dae71be (diff) | |
download | mana-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.tar.gz mana-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.tar.bz2 mana-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.tar.xz mana-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.zip |
Reduced CPU consumption by setting speed per ticks value only once.
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp index 1e6da93e..6ce2120a 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -534,17 +534,11 @@ void Being::logic() // When we've not reached our destination, move to it. if (nominalLength > 1.0f && mWalkSpeed > 0.0f) { - // The private mWalkSpeed member is the speed in tiles per second. - // We translate it into pixels per tick, - // because the logic is called every ticks. - const float speedInTicks = ((float)DEFAULT_TILE_SIDE_LENGTH * mWalkSpeed) - / 1000 * (float)MILLISECONDS_IN_A_TICK; - // The deplacement of a point along a vector is calculated // using the Unit Vector (â) multiplied by the point speed. // â = a / ||a|| (||a|| is the a length.) // Then, diff = (dir/||dir||)*speed, or (dir / ||dir|| / 1/speed). - Vector diff = (dir / (nominalLength / speedInTicks)); + Vector diff = (dir / (nominalLength / mWalkSpeed)); // Test if we don't miss the destination by a move too far: if (diff.length() > nominalLength) |