-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphysicalobject.cpp
More file actions
114 lines (95 loc) · 1.9 KB
/
Copy pathphysicalobject.cpp
File metadata and controls
114 lines (95 loc) · 1.9 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
107
108
109
110
111
112
113
114
#include "physicalobject.h"
#include <QDebug>
int PhysicalObject::getItsBlockX() const
{
return itsBlockX;
}
void PhysicalObject::setItsBlockX(int value)
{
itsBlockX = value;
itsX = blockToPixel(itsBlockX);
}
int PhysicalObject::getItsBlockY() const
{
return itsBlockY;
}
void PhysicalObject::setItsBlockY(int value)
{
itsBlockY = value;
itsY = blockToPixel(itsBlockY);
}
int PhysicalObject::getItsY() const
{
return itsY;
}
void PhysicalObject::setItsY(int value)
{
itsY = value;
itsBlockY = pixelToBlock(itsY);
}
int PhysicalObject::getItsX() const
{
return itsX;
}
void PhysicalObject::setItsX(int value)
{
itsX = value;
itsBlockX = pixelToBlock(itsX);
}
int PhysicalObject::getItsWidth() const
{
return itsWidth;
}
void PhysicalObject::setItsWidth(int value)
{
itsWidth = value;
}
int PhysicalObject::getItsHeight() const
{
return itsHeight;
}
void PhysicalObject::setItsHeight(int value)
{
itsHeight = value;
}
PhysicalObject::PhysicalObject()
{
itsBlockX =0;
itsBlockY = 0;
itsX =0;
itsY = 0;
itsHeight = 0;
itsWidth = 0;
}
PhysicalObject::~PhysicalObject()
{
}
int PhysicalObject::isCollide(PhysicalObject anObject1, PhysicalObject anObject2)
{
int beReturn = 0;
QRect rect1 = QRect(anObject1.getItsX(),anObject1.getItsY(),anObject1.getItsWidth(),anObject1.getItsHeight());
QRect rect2 = QRect(anObject2.getItsX(),anObject2.getItsY(),anObject2.getItsWidth(),anObject2.getItsHeight());
if(rect1.intersects(rect2))
{
return 1;
}
else
{
return 2;
}
/*
if(y1<y4 && y1>y3)
{
if(y2<y4 && y2>y3)
{
if(x1<x4 && x1>x3)
{
if(x2<x4 && x2>x3)
{
beReturn = 1;
}
}
}
}*/
return beReturn;
}