From 8bde9095c5840b8d62ebafe11beaed98877d6ac2 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 9 Oct 2005 03:34:45 +0000 Subject: * 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. --- src/floor_item.h | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'src/floor_item.h') 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; }; -- cgit v1.2.3-70-g09d2