diff options
author | Jan-Fabian Humann <malastare@gmx.net> | 2005-02-28 20:35:08 +0000 |
---|---|---|
committer | Jan-Fabian Humann <malastare@gmx.net> | 2005-02-28 20:35:08 +0000 |
commit | 15383fabbacec848b5735fa0f728bb6242c6ce0e (patch) | |
tree | 811d6b007cec21635caf8c7945d4384ae30c5d25 /src/graphic | |
parent | 8a21b07ae278697e401a8be25d96d5989f5aeacd (diff) | |
download | mana-client-15383fabbacec848b5735fa0f728bb6242c6ce0e.tar.gz mana-client-15383fabbacec848b5735fa0f728bb6242c6ce0e.tar.bz2 mana-client-15383fabbacec848b5735fa0f728bb6242c6ce0e.tar.xz mana-client-15383fabbacec848b5735fa0f728bb6242c6ce0e.zip |
Adding support for drop items part 2/2
Diffstat (limited to 'src/graphic')
-rw-r--r-- | src/graphic/graphic.cpp | 33 | ||||
-rw-r--r-- | src/graphic/graphic.h | 5 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index ce4bc4a1..aa27e8ba 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -29,8 +29,10 @@ #include "../gui/equipment.h" #include "../gui/newskill.h" #include "../gui/chargedialog.h" +#include "../gui/itemcontainer.h" #include "../main.h" #include "../being.h" +#include "../floor_item.h" #ifdef USE_OPENGL #include <SDL_opengl.h> #endif @@ -321,16 +323,20 @@ Engine::Engine() "core/graphics/sprites/monsters.png"); Image *weaponbitmap = resman->getImage( "core/graphics/sprites/weapons.png"); + Image *itembitmap = resman->getImage( + "core/graphics/sprites/items.png"); if (!npcbmp) error("Unable to load npcs.png"); if (!emotionbmp) error("Unable to load emotions.png"); if (!monsterbitmap) error("Unable to load monsters.png"); if (!weaponbitmap) error("Unable to load weapons.png"); + if (!itembitmap) error("Unable to load items.png"); npcset = new Spriteset(npcbmp, 50, 80); emotionset = new Spriteset(emotionbmp, 19, 19); monsterset = new Spriteset(monsterbitmap, 60, 60); weaponset = new Spriteset(weaponbitmap, 160, 120); + itemset = new Spriteset(itembitmap, 20, 20); } Engine::~Engine() @@ -353,6 +359,7 @@ Engine::~Engine() delete npcset; delete emotionset; delete weaponset; + delete itemset; } void Engine::draw() @@ -388,7 +395,33 @@ void Engine::draw() } } } + + // Draw items + std::list<FloorItem*>::iterator floorItemIterator = floorItems.begin(); + while (floorItemIterator != floorItems.end()) + { + FloorItem *floorItem = (*floorItemIterator); + unsigned short x = floorItem->x; + unsigned short y = floorItem->y; + int sx = x - camera_x; + int sy = y - camera_y; + int absx = sx * 32 - floorItem->subx - offset_x; + int absy = sy * 32 - floorItem->suby - offset_y; + /** + * subx and suby are serverside randomly generated to be + * either 3, 6, 9 or 12. + * this seems to be a finer differentiation for coordinates. + * TODO: Find a better way to implement subx and suby. + */ + if (floorItem->id >= 501 && floorItem->id <= 1202) { + itemset->spriteset[floorItem->id - 501]->draw(screen, + absx, + absy); + } + floorItemIterator++; + } + // Draw nodes std::list<Being*>::iterator beingIterator = beings.begin(); while (beingIterator != beings.end()) diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index b85c29ae..b3903c9a 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -162,8 +162,9 @@ class Graphics : public gcn::SDLGraphics { */ class Engine { private: - Spriteset *emotionset, *npcset, *monsterset, *weaponset; - + Spriteset *emotionset, *npcset, *monsterset, *weaponset, *itemset; + // Fix this number to an appropriate + public: Engine(); ~Engine(); |