summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorunknown <Philipp@.(none)>2011-08-20 18:02:06 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-02 00:22:47 +0200
commitad9ba099aeef6b27cd0843761fa15ebfa3061bf0 (patch)
tree66f10806366e11fd7a85f3a431e6e25c090855c1 /src
parent5d00678217e5198cb375b4a2214a3e056151bdd9 (diff)
downloadmana-ad9ba099aeef6b27cd0843761fa15ebfa3061bf0.tar.gz
mana-ad9ba099aeef6b27cd0843761fa15ebfa3061bf0.tar.bz2
mana-ad9ba099aeef6b27cd0843761fa15ebfa3061bf0.tar.xz
mana-ad9ba099aeef6b27cd0843761fa15ebfa3061bf0.zip
The draw order of particles is now Y - 16 pixels.
This means that the order point of the sprites relative to the particles is no longer the lowest point of the image but instead a point which is approximately between the feet of the characters. The intent of the latest commits to treat sprites as perpendicular to the ground instead of perpendicular to the view line is retained by this approach. I tested this with various particle effects and it results in exactly the expected behavior. Note that this does NOT fix the current problems on TMW with the snail slime effect, because the TMW content team accidently placed this one 10px in the air. Sorry, garbage in, garbage out. getDrawPixelY was re-renamed to getPixelY to be consistent with getPixelX, while getPixelY was renamed to getDrawOrder, to make its purpose clear. Further, particles are no longer drawn when behind other objects. This is implemented by adding a drawnWhenBehind member function to Actor, which currently returns true for everything except particles and compound- sprites with more than one sub-sprites (the later case is consistent with the previous behavior of them). An exception are text particles which are excempt from this exception and whose drawing order is also biased by 16 pixels south instead of north to make them more visible. Plus some minor changes from Bertram. Reviewed-by: Bertram. Resolves: Mana-Mantis #362.
Diffstat (limited to 'src')
-rw-r--r--src/actor.h9
-rw-r--r--src/actorsprite.cpp2
-rw-r--r--src/animatedsprite.h3
-rw-r--r--src/being.cpp14
-rw-r--r--src/being.h3
-rw-r--r--src/compoundsprite.cpp6
-rw-r--r--src/compoundsprite.h2
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/map.cpp4
-rw-r--r--src/particle.cpp5
-rw-r--r--src/particle.h9
-rw-r--r--src/textparticle.h11
12 files changed, 54 insertions, 16 deletions
diff --git a/src/actor.h b/src/actor.h
index 240b5097..e2c32a94 100644
--- a/src/actor.h
+++ b/src/actor.h
@@ -89,10 +89,17 @@ public:
/**
* Returns the pixel Y coordinate that the actor should be drawn at.
*/
- virtual int getDrawPixelY() const
+ virtual int getDrawOrder() const
{ return getPixelY(); }
/**
+ * Determines wether the actor should be drawn translucent when behind
+ * another object
+ */
+ virtual bool drawnWhenBehind() const
+ { return false; }
+
+ /**
* Returns the x coordinate in tiles of the actor.
*/
virtual int getTileX() const;
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index e89ba3c8..8dc873da 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -69,7 +69,7 @@ ActorSprite::~ActorSprite()
bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
{
int px = getPixelX() + offsetX;
- int py = getDrawPixelY() + offsetY;
+ int py = getPixelY() + offsetY;
if (mUsedTargetCursor)
{
diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index a5d91095..5a19ee0d 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -77,6 +77,9 @@ class AnimatedSprite : public Sprite
int getNumberOfLayers()
{ return 1; }
+ virtual bool drawnWhenBehind() const
+ { return true; }
+
size_t getCurrentFrame() const;
size_t getFrameCount() const;
diff --git a/src/being.cpp b/src/being.cpp
index 6c2a1517..04cd6719 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -301,7 +301,7 @@ void Being::setSpeech(const std::string &text, int time)
delete mText;
mText = new Text(mSpeech,
- getPixelX(), getDrawPixelY() - getHeight(),
+ getPixelX(), getPixelY() - getHeight(),
gcn::Graphics::CENTER,
&userPalette->getColor(UserPalette::PARTICLE),
true);
@@ -364,7 +364,7 @@ void Being::takeDamage(Being *attacker, int amount,
// Show damage number
particleEngine->addTextSplashEffect(damage,
- getPixelX(), getDrawPixelY() - 16,
+ getPixelX(), getPixelY() - getHeight(),
color, font, true);
if (amount > 0)
@@ -907,7 +907,7 @@ void Being::logic()
void Being::drawSpeech(int offsetX, int offsetY)
{
const int px = getPixelX() - offsetX;
- const int py = getDrawPixelY() - offsetY;
+ const int py = getPixelY() - offsetY;
const int speech = config.getIntValue("speech");
// Draw speech above this being
@@ -941,7 +941,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
if (! mText)
{
mText = new Text(mSpeech,
- getPixelX(), getDrawPixelY() - getHeight(),
+ getPixelX(), getPixelY() - getHeight(),
gcn::Graphics::CENTER,
&userPalette->getColor(UserPalette::PARTICLE),
true);
@@ -965,9 +965,9 @@ void Being::updateCoords()
// Monster names show above the sprite instead of below it
if (getType() == MONSTER)
- mDispName->adviseXY(getPixelX(), getDrawPixelY() - getHeight());
+ mDispName->adviseXY(getPixelX(), getPixelY() - getHeight());
else
- mDispName->adviseXY(getPixelX(), getDrawPixelY() + mDispName->getHeight());
+ mDispName->adviseXY(getPixelX(), getPixelY() + mDispName->getHeight());
}
void Being::flashName(int time)
@@ -1016,7 +1016,7 @@ void Being::showName()
font = boldFont;
}
- mDispName = new FlashText(mDisplayName, getPixelX(), getDrawPixelY(),
+ mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(),
gcn::Graphics::CENTER, mNameColor, font);
updateCoords();
diff --git a/src/being.h b/src/being.h
index b702cf1a..c6fd63ed 100644
--- a/src/being.h
+++ b/src/being.h
@@ -279,6 +279,9 @@ class Being : public ActorSprite, public EventListener
*/
int getNumberOfLayers() const;
+ virtual bool drawnWhenBehind() const
+ { return CompoundSprite::drawnWhenBehind(); }
+
/**
* Performs being logic.
*/
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 5214890c..6e8af72e 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -158,6 +158,12 @@ int CompoundSprite::getNumberOfLayers() const
return size();
}
+bool CompoundSprite::drawnWhenBehind() const
+{
+ // For now, just draw actors with only one layer when obscured
+ return (getNumberOfLayers() == 1);
+}
+
size_t CompoundSprite::getCurrentFrame() const
{
SpriteConstIterator it, it_end;
diff --git a/src/compoundsprite.h b/src/compoundsprite.h
index 17fdfd18..d91193b3 100644
--- a/src/compoundsprite.h
+++ b/src/compoundsprite.h
@@ -66,6 +66,8 @@ public:
int getNumberOfLayers() const;
+ virtual bool drawnWhenBehind() const;
+
size_t getCurrentFrame() const;
size_t getFrameCount() const;
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 3c1cc259..78395438 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -115,7 +115,7 @@ void LocalPlayer::logic()
particleEngine->addTextRiseFadeOutEffect(
info.first,
getPixelX(),
- getDrawPixelY() - 48,
+ getPixelY() - 32 - 16,
&userPalette->getColor(info.second),
gui->getInfoParticleFont(), true);
diff --git a/src/map.cpp b/src/map.cpp
index f95284b4..ac287be4 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -325,7 +325,7 @@ void Map::addTileset(Tileset *tileset)
bool actorCompare(const Actor *a, const Actor *b)
{
- return a->getPixelY() < b->getPixelY();
+ return a->getDrawOrder() < b->getDrawOrder();
}
void Map::update(int ticks)
@@ -403,7 +403,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
if (Actor *actor = *ai)
{
// For now, just draw actors with only one layer.
- if (actor->getNumberOfLayers() == 1)
+ if (actor->drawnWhenBehind())
{
actor->setAlpha(0.3f);
actor->draw(graphics, -scrollX, -scrollY);
diff --git a/src/particle.cpp b/src/particle.cpp
index 4d6882be..4b8833eb 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -453,6 +453,11 @@ float Particle::getCurrentAlpha() const
return alpha;
}
+int Particle::getDrawOrder() const
+{
+ return (int)(mPos.y) - 16;
+}
+
void Particle::clear()
{
delete_all(mChildEmitters);
diff --git a/src/particle.h b/src/particle.h
index a09648ee..7ba80a3c 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -95,8 +95,13 @@ class Particle : public Actor
/**
* Necessary for sorting with the other sprites.
*/
- virtual int getDrawPixelY() const
- { return (int) (mPos.y + mPos.z) - 64; }
+ virtual int getDrawOrder() const;
+
+ /**
+ * Do not draw particles when beind other objects
+ */
+ virtual bool drawnWhenBehind() const
+ { return false; }
/**
* Creates a blank particle as a child of the current particle
diff --git a/src/textparticle.h b/src/textparticle.h
index 2791cb03..61241308 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -37,8 +37,15 @@ class TextParticle : public Particle
virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const;
// hack to improve text visibility
- virtual int getPixelY() const
- { return (int) (mPos.y + mPos.z); }
+ virtual int getDrawOrder() const
+ { return (int) (mPos.y) + 32; }
+
+ /** In contrary to other particles, text particles should not be
+ * obscured by objects, because their information is too
+ * important.
+ */
+ virtual bool drawnWhenBehind() const
+ { return true; }
private:
std::string mText; /**< Text of the particle. */