From 51629a66ff14a9025d9bd9ea69831e3d824a0760 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 30 Apr 2017 16:16:41 -0400 Subject: mem track+, drop func. added --- src/inventory.cpp | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'src/inventory.cpp') diff --git a/src/inventory.cpp b/src/inventory.cpp index 434eac6..96c1d6d 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -219,25 +219,45 @@ void InventorySystem::receive(const MouseReleaseEvent &mre) } } - auto e = game::entities.create(); - e.assign(mre.position.x, mre.position.y); - e.assign(0, 0.1f); - e.assign(items[movingItem]); - e.assign(); - e.component()->addSpriteSegment( - SpriteData(items[movingItem].item->sprite), vec2(0, 0)); - auto dim = items[movingItem].item->sprite.getDim(); - e.assign(HLINES(dim.x), HLINES(dim.y)); - e.assign(); - e.assign(); - + makeDrop(mre.position, items[movingItem]); items[movingItem].item = nullptr; items[movingItem].count = 0; - movingItem = -1; } } +void InventorySystem::makeDrop(const vec2& p, InventoryEntry& ie) +{ + auto e = game::entities.create(); + e.assign(p.x, p.y); + e.assign(0, 0.1f); + e.assign(ie); + e.assign(); + e.component()->addSpriteSegment( + SpriteData(ie.item->sprite), vec2(0, 0)); + auto dim = ie.item->sprite.getDim(); + e.assign(HLINES(dim.x), HLINES(dim.y)); + e.assign(); + e.assign(); +} + +void InventorySystem::makeDrop(const vec2& p, const std::string& s, int c) +{ + auto item = getItem(s); + auto e = game::entities.create(); + e.assign(p.x, p.y); + e.assign(0, 0.1f); + InventoryEntry ie (item, c); + e.assign(ie); + e.assign(); + e.component()->addSpriteSegment( + SpriteData(item->sprite), vec2(0, 0)); + auto dim = item->sprite.getDim(); + e.assign(HLINES(dim.x), HLINES(dim.y)); + e.assign(); + e.assign(); +} + void InventorySystem::receive(const KeyDownEvent &kde) { if (kde.keycode == SDLK_e) { -- cgit v1.2.3