-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard.cpp
More file actions
107 lines (89 loc) · 2.15 KB
/
card.cpp
File metadata and controls
107 lines (89 loc) · 2.15 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "card.h"
Card::Card(const short &val, const char &n, const char &c)
{
default_val=val;
name=n;
color=c;
//setCenterPosition();
}
Card::Card(const std::string &txt_name, const std::map<std::string, sf::Texture> &txt)
{
loadTextures(txt_name, txt);
//setCenterPosition();
}
Card::Card(const short &val, const std::string &txt_name, const std::map<std::string, sf::Texture> &txt, const int &x, const int &y, const int &xx, const int &yy)
{
default_val=val;
loadTexture(txt_name, txt, x, y, xx, yy);
//setCenterPosition();
}
Card::Card(const short &val, const char &n, const char &c, const std::string &txt_name, const std::map<std::string, sf::Texture> &txt, const int &x, const int &y, const int &xx, const int &yy)
{
default_val=val;
name=n;
color=c;
loadTexture(txt_name, txt, x, y, xx, yy);
//setCenterPosition();
}
char Card::getName()
{
return name;
}
char Card::getColor()
{
return color;
}
void Card::setValue(short &val)
{
actual_val=val;
}
void Card::setValueZero()
{
actual_val=0;
}
void Card::setValueDefault()
{
actual_val=default_val;
}
void Card::addValue(const short &val)
{
actual_val=default_val+val;
}
void Card::setCenterPosition()
{
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
}
short Card::getValue()
{
return actual_val;
}
short Card::getDefaultValue()
{
return default_val;
}
void Card::setPlayer(const short &val)
{
player=val;
}
short Card::getPlayer()
{
return player;
}
void Card::loadTextures(const std::string &txt_name, const std::map<std::string, sf::Texture> &txt)
{
for(auto &i : txt){if(txt_name==i.first){this->setTexture(i.second);}}
}
void Card::loadTexture(const std::string &txt_name, const std::map<std::string, sf::Texture> &txt, const int &x, const int &y, const int &xx, const int &yy)
{
for(auto &i : txt)
{
if(txt_name==i.first)
{
this->setTexture(i.second);
this->setTextureRect({x,y,xx,yy});
}
}
float tempx=round(this->getLocalBounds().width/2);
float tempy=round(this->getLocalBounds().height/2);
this->setOrigin(tempx, tempy);
}