-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathobject.cpp
78 lines (65 loc) · 1.03 KB
/
object.cpp
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
#include "object.h"
Object::Object(int x_temp,int y_temp,int num,QWidget *widget)
{
obj=new QLabel(widget);
if(num==1){
obj_.load("Images/tree.png");
obj->setFixedSize(150,150);
}
else{
obj_.load("Images/gun.png");
obj->setFixedSize(100,100);
}
obj->setPixmap(obj_);
obj->setScaledContents(1);
x=x_temp;
y=y_temp;
obj->show();
}
void Object::relMove(int a,int b)
{
rel_x=x-a;
rel_y=y-b;
}
void Object::draw()
{
if(isEquipped==1){
obj->move(CENTER_X,CENTER_Y+20);
}
else if(isEquipped==2){
obj->move(x2+rel_x,y2+rel_y);
}
else{
obj->move(CENTER_X+rel_x,CENTER_Y+rel_y);
}
}
int Object::getY()
{
return y;
}
void Object::Raise()
{
obj->raise();
}
void Object::Lower()
{
obj->lower();
}
bool Object::IsEquipped()
{
return isEquipped;
}
void Object::equip()
{
isEquipped=1;
}
void Object::equip2(int x_temp,int y_temp)
{
x2=x_temp;
y2=y_temp;
isEquipped=2;
}
int Object::getX()
{
return x;
}