Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Image quantity fixed on dropped items #174

Merged
merged 1 commit into from
Jul 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/core/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ class Map {
&& (this.player.x >= (item.x - 8))
&& (this.player.y <= (6 + item.y))
&& (this.player.y >= (item.y - 6));

return foundItems;
});

Expand All @@ -251,8 +250,15 @@ class Map {
y: Math.floor(this.config.map.viewport.y / 2) - (this.player.y - item.y),
};

// Get item information
// Get item information and get proper quantity index for graphic
const info = UI.getItemData(item.id);
let qtyIndex = 0;
if (item.qty > 1 && info.graphics.quantityLevel) {
const qLevels = info.graphics.quantityLevel;
while (qtyIndex < qLevels.length - 1 && qLevels[qtyIndex] < item.qty) {
qtyIndex += 1;
}
}

// Get the correct tileset to draw upon
const itemTileset = () => {
Expand All @@ -272,7 +278,7 @@ class Map {
// Paint the item on map
this.context.drawImage(
itemTileset(),
(info.graphics.column * 32), // Number in Item tileset
((info.graphics.column + qtyIndex) * 32), // Number in Item tileset
(info.graphics.row * 32), // Y-axis of tileset
32,
32,
Expand Down