diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-09 03:34:45 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-09 03:34:45 +0000 |
commit | 8bde9095c5840b8d62ebafe11beaed98877d6ac2 (patch) | |
tree | 537f717a339d1247cae222eb7a354ea5dbe8babf /src/floor_item.h | |
parent | a246c08cef5e4d598fc07a681eb971bfbcf01519 (diff) | |
download | mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.gz mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.bz2 mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.xz mana-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/floor_item.h')
-rwxr-xr-x | src/floor_item.h | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/floor_item.h b/src/floor_item.h index 5563da24..e004c0a2 100755 --- a/src/floor_item.h +++ b/src/floor_item.h @@ -24,14 +24,16 @@ #ifndef _TMW_FLOORITEM_H_ #define _TMW_FLOORITEM_H_ -class Map; - +#include "graphics.h" #include "map.h" +#include "sprite.h" + +class Map; /** * An item lying on the floor. */ -class FloorItem +class FloorItem : public Sprite { public: /** @@ -51,28 +53,53 @@ class FloorItem /** * Returns instance id of this item. */ - unsigned int getId() { return mId; } + unsigned int + getId() { return mId; } /** * Returns the item id. */ - unsigned int getItemId() { return mItemId; } + unsigned int + getItemId() { return mItemId; } /** * Returns the x coordinate. */ - unsigned short getX() { return mX; } + unsigned short + getX() { return mX; } /** * Returns the y coordinate. */ - unsigned short getY() { return mY; } + unsigned short + getY() { return mY; } + + /** + * Returns the pixel y coordinate. + * + * @see Sprite::getPixelY() + */ + int + getPixelY() const { return mY * 32; } + + /** + * Draws this floor item to the given graphics context. + * + * @see Sprite::draw(Graphics, int, int) + */ + void + draw(Graphics *graphics, int offsetX, int offsetY) + { + graphics->drawImage(mImage, + mX * 32 + offsetX, + mY * 32 + offsetY); + } private: unsigned int mId; unsigned int mItemId; unsigned short mX, mY; - Sprite *mSprite; + Image *mImage; Sprites::iterator mSpriteIterator; Map *mMap; }; |