-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShopItem.cpp
More file actions
45 lines (37 loc) · 1.31 KB
/
ShopItem.cpp
File metadata and controls
45 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "ShopItem.h"
// Constructor to initialize a shop item
ShopItem::ShopItem(const std::string& itemName, int itemCost, const std::string& itemDescription, const std::string& textureFile)
: name(itemName), cost(itemCost), description(itemDescription) {
// Load texture from file
if (!itemTexture.loadFromFile(textureFile)) {
std::cerr << "Error loading texture for " << itemName << " from " << textureFile << "\n";
}
else {
itemSprite.setTexture(itemTexture);
}
}
// Getter for item name
std::string ShopItem::getName() const {
return name;
}
// Getter for item cost
int ShopItem::getCost() const {
return cost;
}
// Getter for item description
std::string ShopItem::getDescription() const {
return description;
}
// Draw method to render item image
void ShopItem::draw(sf::RenderWindow& window, float x, float y) {
itemSprite.setPosition(x, y); // Set position
window.draw(itemSprite); // Draw sprite
}
// Virtual function for applying an item's effect on player and enemy
void ShopItem::applyEffect(Player* player, Enemy* enemy) {
// (to be overridden in child classes)
}
// Virtual function for applying an item's effect to a customer
void ShopItem::applyCustomerEffect(Player* player, CustomerEntity* customer) {
// (to be overridden in child classes)
}