const Items = { items: new Map(), // Map of items on the grid, key is "q,r" // Item types TYPES: { COIN: { name: 'Coin', color: '#FFD700', size: 0.2 // Size relative to hex }, GEM: { name: 'Gem', color: '#50C878', size: 0.25 } }, // Initialize items on the map init() { this.items.clear(); // Add some random items for (let i = 0; i < 10; i++) { const q = Math.floor(Math.random() * HexGrid.GRID_SIZE - HexGrid.GRID_SIZE/2); const r = Math.floor(Math.random() * HexGrid.GRID_SIZE - HexGrid.GRID_SIZE/2); // Don't place items at player start position if (q !== 0 || r !== 0) { const type = Math.random() < 0.5 ? this.TYPES.COIN : this.TYPES.GEM; this.addItem(q, r, type); } } }, // Add an item to the map addItem(q, r, type) { this.items.set(`${q},${r}`, { type, q, r }); }, // Remove an item from the map removeItem(q, r) { return this.items.delete(`${q},${r}`); }, // Get item at position getItem(q, r) { return this.items.get(`${q},${r}`); }, // Draw all items draw(ctx, hexToPixel, camera, HEX_SIZE) { this.items.forEach(item => { const pixelPos = hexToPixel({ q: item.q, r: item.r }); const screenX = pixelPos.x - camera.x; const screenY = pixelPos.y - camera.y; ctx.fillStyle = item.type.color; ctx.beginPath(); ctx.arc(screenX, screenY, HEX_SIZE * item.type.size, 0, Math.PI * 2); ctx.fill(); }); } };