-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimal.cpp
More file actions
93 lines (77 loc) · 1.26 KB
/
animal.cpp
File metadata and controls
93 lines (77 loc) · 1.26 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
#include "animal.h"
#include <iostream>
using namespace std;
Animal::Animal(QString file, int xD, int yD)
{
image.load(file);
rect = image.rect();
appear = false;
xDir = xD;
yDir = yD;
}
Animal::~Animal()
{
cout<<"Animal deleted"<<endl;
}
void Animal::setPosition(int xPos, int yPos)
{
rect.moveTo(xPos, yPos);
}
void Animal::resetState()
{
rect.moveTo(0,100);
appear = false;
}
bool Animal::isAppear()
{
return appear;
}
void Animal::setAppear(bool b)
{
appear = b;
}
void Animal::moveLeft(int left)
{
if (rect.left() >= 0) //Change depending on window size
rect.moveTo(left, rect.top());
}
void Animal::moveRight(int right)
{
if (rect.right() <= 388) //Change depending on window size
rect.moveTo(right, rect.top());
}
void Animal::moveUp(int up)
{
if (rect.top() >= 2) //change depending on window size
rect.moveTo(rect.left(), up);
}
void Animal::moveDown(int down)
{
if (rect.bottom() <= 458) //change depending on window size
rect.moveTo(rect.left(), down);
}
int Animal::getXD()
{
return xDir;
}
void Animal::setXD(int x)
{
xDir = x;
}
int Animal::getYD()
{
return yDir;
}
void Animal::setYD(int y)
{
yDir = y;
}
//void Animal::automove(){;}
QRect Animal::getRect()
{
return rect;
}
QImage & Animal::getImage()
{
return image;
}