StopFollowers(*controlled);
if (!moveTimer.Running()) {
int tileSize((controlled->GetOrientation() % 2) ? map->Tileset()->Width() : map->Tileset()->Height());
- moveTimer = PhysicsTimers().StartInterval(tileSize/walkingSpeed.Int());
+ Fixed<8> walkingInterval(tileSize);
+ walkingInterval /= walkingSpeed;
+ moveTimer = PhysicsTimers().StartInterval(walkingInterval.Int());
}
pushed = 0;
}
}
return *this;
}
- Fixed &operator +=(int i) {
+ template<class Scalar>
+ Fixed &operator +=(Scalar i) {
Sint32 temp = SignedInt() + (i << IntShift());
if (temp < 0) {
rep = (temp * -1) | SignMask();
}
return *this;
}
- Fixed &operator -=(int i) {
+ template<class Scalar>
+ Fixed &operator -=(Scalar i) {
Sint32 temp = SignedInt() - (i << IntShift());
if (temp < 0) {
rep = (temp * -1) | SignMask();
}
return *this;
}
- Fixed &operator *=(int i) {
+ template<class Scalar>
+ Fixed &operator *=(Scalar i) {
Sint32 temp = SignedInt() * i;
if (temp < 0) {
rep = (temp * -1) | SignMask();
}
return *this;
}
- Fixed &operator /=(int i) {
+ template<class Scalar>
+ Fixed &operator /=(Scalar i) {
Sint32 temp = SignedInt() / i;
if (temp < 0) {
rep = (temp * -1) | SignMask();
CPPUNIT_ASSERT_EQUAL(
Fixed(5),
Fixed(2) * Fixed(2.5));
+ CPPUNIT_ASSERT_EQUAL(
+ Fixed(8),
+ Fixed(2) * 4);
CPPUNIT_ASSERT_EQUAL(
Fixed(-1.7499999999),
Fixed(3, 4) * Fixed(-7, 3));
+ CPPUNIT_ASSERT_EQUAL(
+ Fixed(-1.7499999999),
+ Fixed(3, 4) * Fixed(-2.33333333));
CPPUNIT_ASSERT_EQUAL(
Fixed(4),
Fixed(2) / Fixed(0.5));
+ CPPUNIT_ASSERT_EQUAL(
+ Fixed(4),
+ Fixed(2) / 0.5);
CPPUNIT_ASSERT_EQUAL(
Fixed(3),
Fixed(15) / Fixed(5));
+ CPPUNIT_ASSERT_EQUAL(
+ Fixed(3),
+ Fixed(15) / 5);
}
void FixedTest::testModulo() {