aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2013-10-06 14:38:52 +0200
committerStrangerke2013-10-06 14:38:52 +0200
commit6216430428724e8d833736d00cb807b14507bd9c (patch)
treec385762e072b7d18be71a62bc4264cb3a07027c6 /engines
parentac231eb83870c189261b231d44eff366e354b6dd (diff)
downloadscummvm-rg350-6216430428724e8d833736d00cb807b14507bd9c.tar.gz
scummvm-rg350-6216430428724e8d833736d00cb807b14507bd9c.tar.bz2
scummvm-rg350-6216430428724e8d833736d00cb807b14507bd9c.zip
AVALANCHE: Rework bearing()
Diffstat (limited to 'engines')
-rw-r--r--engines/avalanche/avalot.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index e6cf310d54..8e70d7b2aa 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -30,7 +30,6 @@
#include "avalanche/avalanche.h"
#include "common/random.h"
#include "common/config-manager.h"
-#include <math.h>
namespace Avalanche {
@@ -1361,16 +1360,18 @@ void AvalancheEngine::majorRedraw() {
}
uint16 AvalancheEngine::bearing(byte whichPed) {
- const float rad2deg = 180 / M_PI;
AnimationType *avvy = &_animation->_sprites[0];
PedType *curPed = &_peds[whichPed];
if (avvy->_x == curPed->_x)
return 0;
- else if (avvy->_x < curPed->_x) {
- return (uint16)((atan(double((avvy->_y - curPed->_y)) / (avvy->_x - curPed->_x)) * rad2deg) + 90);
+
+ int16 deltaX = avvy->_x - curPed->_x;
+ int16 deltaY = avvy->_y - curPed->_y;
+ if (deltaX < 0) {
+ return (uint16)((atan((float)(deltaY / deltaX)) * 180 / M_PI) + 90);
} else {
- return (uint16)((atan(double((avvy->_y - curPed->_y)) / (avvy->_x - curPed->_x)) * rad2deg) + 270);
+ return (uint16)((atan((float)(deltaY / deltaX)) * 180 / M_PI) + 270);
}
}