summaryrefslogtreecommitdiff
path: root/src/flooritem.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-05-02 14:43:40 -0600
committerJared Adams <jaxad0127@gmail.com>2010-05-06 22:21:57 -0600
commit9baedc27191c82bbf1fedee2a7e738bc5b267c0e (patch)
treef0986c6839d1e79b402d5d4ec36e4994741955ea /src/flooritem.cpp
parent844e9a7a72faca6a212e788a3adc45e17f41dca6 (diff)
downloadmana-client-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.gz
mana-client-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.bz2
mana-client-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.xz
mana-client-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.zip
Add support for floor item sprites
This commit adds a sprite hierarchy (Sprite->ImageSprite,AnimatedSprite,CompundSprite; CompoundSprite,Actor->ActorSprite;ActorSprite->Being,FloorItem) to collect common functionailty into new base classes which will make other Mantis tickets easier to do. Also allows monsters to use particle effects. Reviewed-by: Bertram
Diffstat (limited to 'src/flooritem.cpp')
-rw-r--r--src/flooritem.cpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index e5a9d215..84e07f35 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -21,52 +21,34 @@
#include "flooritem.h"
-#include "graphics.h"
-#include "item.h"
-#include "map.h"
+#include "net/net.h"
-#include "resources/image.h"
+#include "resources/itemdb.h"
+#include "resources/iteminfo.h"
FloorItem::FloorItem(int id,
int itemId,
int x,
int y,
Map *map):
- mId(id)
+ ActorSprite(id),
+ mItemId(itemId),
+ mX(x),
+ mY(y)
{
setMap(map);
- mPos.x = x * map->getTileWidth();
- mPos.y = y * map->getTileHeight();
- // Create a corresponding item instance
- mItem = new Item(itemId);
-}
-FloorItem::~FloorItem()
-{
- delete mItem;
-}
+ // TODO: Eventually, we probably should fix all sprite offsets so that
+ // these translations aren't necessary anymore. The sprites know
+ // best where their base point should be.
+ mPos.x = x * map->getTileWidth() + 16;
+ mPos.y = y * map->getTileHeight() +
+ ((Net::getNetworkType() == ServerInfo::MANASERV) ? 15 : 32);
-int FloorItem::getItemId() const
-{
- return mItem->getId();
+ setupSpriteDisplay(ItemDB::get(itemId).getDisplay());
}
-Item *FloorItem::getItem() const
+const ItemInfo &FloorItem::getInfo() const
{
- return mItem;
-}
-
-void FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
-{
- if (mItem)
- {
- Image *image = mItem->getDrawImage();
-
- if (image)
- if (mAlpha != image->getAlpha())
- image->setAlpha(mAlpha);
-
- graphics->drawImage(image, getPixelX() + offsetX,
- getPixelY() + offsetY);
- }
+ return ItemDB::get(mId);
}