From 31782ba3cdeced9baa91739c55e9ae819d70d616 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 5 Mar 2016 02:38:49 +0300 Subject: Add pixel position into actor. --- src/being/actor.cpp | 9 +++++++++ src/being/actor.h | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/being/actor.cpp b/src/being/actor.cpp index b66435739..aebf00adb 100644 --- a/src/being/actor.cpp +++ b/src/being/actor.cpp @@ -26,6 +26,8 @@ #include "debug.h" Actor::Actor() : + mPixelX(0), + mPixelY(0), mMap(nullptr), mPos(), mYDiff(0), @@ -70,3 +72,10 @@ int Actor::getTileY() const return getPixelY() / mMap->getTileHeight(); } + +void Actor::setPixelPositionF(const Vector &restrict pos) restrict2 +{ + mPos = pos; + mPixelX = CAST_S32(mPos.x); + mPixelY = CAST_S32(mPos.y); +} diff --git a/src/being/actor.h b/src/being/actor.h index 0b83e46be..72a9810ee 100644 --- a/src/being/actor.h +++ b/src/being/actor.h @@ -76,8 +76,7 @@ class Actor notfinal /** * Sets the pixel position of this actor. */ - virtual void setPixelPositionF(const Vector &restrict pos) restrict2 - { mPos = pos; } + virtual void setPixelPositionF(const Vector &restrict pos) restrict2; /** * Returns the pixels X coordinate of the actor. @@ -128,6 +127,9 @@ class Actor notfinal const Map* getMap() const A_WARN_UNUSED { return mMap; } + int mPixelX; + int mPixelY; + protected: Actor(); -- cgit v1.2.3-70-g09d2