-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrap.cpp
More file actions
36 lines (29 loc) · 1.08 KB
/
Scrap.cpp
File metadata and controls
36 lines (29 loc) · 1.08 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
#include "Scrap.h"
// Define the fixed size for all scraps
const sf::Vector2f Scrap::fixedSize(50, 20); // Set the fixed size
// Constructor to initialize the scrap with a name and position
Scrap::Scrap(const std::string& scrapName, const ScrapPosition& position)
: name(scrapName), shape(fixedSize) {
shape.setFillColor(sf::Color::Cyan); // Set color for the scrap item
setPosition(position.x, position.y); // Set the position using the ScrapPosition struct
}
// Get the name of the scrap
std::string Scrap::getName() const {
return name;
}
// Display scrap information in the console
void Scrap::displayInfo() const {
std::cout << "Scrap Name: " << name << std::endl;
}
// Set the position of the scrap's SFML shape
void Scrap::setPosition(float x, float y) {
shape.setPosition(x, y);
}
// Render the scrap on the provided SFML window
void Scrap::draw(sf::RenderWindow& window) const {
window.draw(shape);
}
// Get the global bounds of the scrap
sf::FloatRect Scrap::getGlobalBounds() const {
return shape.getGlobalBounds(); // Return the global bounds of the shape
}