summaryrefslogtreecommitdiff
path: root/src/sprite.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-10-09 03:34:45 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-10-09 03:34:45 +0000
commit8bde9095c5840b8d62ebafe11beaed98877d6ac2 (patch)
tree537f717a339d1247cae222eb7a354ea5dbe8babf /src/sprite.h
parenta246c08cef5e4d598fc07a681eb971bfbcf01519 (diff)
downloadmana-client-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.gz
mana-client-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.bz2
mana-client-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.xz
mana-client-8bde9095c5840b8d62ebafe11beaed98877d6ac2.zip
* Made Sprite into an interface implemented by both FloorItem and Being, which
hook themselves into the map on construction. The improved fringe layer is working as expected now. * Made sure TMW compiles without warnings even when using "-Wconversion -Wshadow -Wcast-qual -Wwrite-strings -ansi -pedantic", lots of cleanups. * Added two new small tilesets that contain the desert tiles that are twice and three times the height of a normal tile. One well in new_3-1 has been converted to use the new double tiles for testing purposes.
Diffstat (limited to 'src/sprite.h')
-rw-r--r--src/sprite.h39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/sprite.h b/src/sprite.h
index 97851138..2950f4e8 100644
--- a/src/sprite.h
+++ b/src/sprite.h
@@ -24,23 +24,20 @@
#ifndef _TMW_SPRITE_H_
#define _TMW_SPRITE_H_
-#include "graphics.h"
+class Graphics;
/**
- * A sprite is some visible object on a map.
+ * A sprite is some visible object on a map. This abstract class defines the
+ * interface used by the map to sort and display the sprite.
*/
class Sprite
{
public:
/**
- * Constructor.
+ * Destructor.
*/
- Sprite(int x = 0, int y = 0, Image *image = NULL):
- mX(x),
- mY(y),
- mImage(image)
- {
- }
+ virtual
+ ~Sprite() {}
/**
* Draws the sprite to the given graphics context.
@@ -49,28 +46,20 @@ class Sprite
* would support setting a translation offset. It already does this
* partly with the clipping rectangle support.
*/
- void
- draw(Graphics *graphics, int offsetX, int offsetY)
- {
- graphics->drawImage(mImage, mX + offsetX, mY + offsetY);
- }
+ virtual void
+ draw(Graphics *graphics, int offsetX, int offsetY) = 0;
/**
- * Returns the X coordinate of the sprite.
+ * Returns the pixel Y coordinate of the sprite.
*/
- int
- getY() const { return mY; }
+ virtual int
+ getPixelY() const = 0;
+ protected:
/**
- * Returns the Y coordinate of the sprite.
+ * Constructor.
*/
- int
- getX() const { return mX; }
-
- private:
- int mX; /**< X coordinate in pixels. */
- int mY; /**< Y coordinate in pixels. */
- Image *mImage; /**< The image currently representing this sprite. */
+ Sprite() {}
};
#endif