-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
58 lines (57 loc) · 896 Bytes
/
Copy pathplayer.cpp
File metadata and controls
58 lines (57 loc) · 896 Bytes
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
#include "player.h"
using namespace std;
//constructor
player::player()
{
image.load("flame.png");
rect = image.rect();
rect.moveTo(500,375);
}
//Return postion of element
QRect player::getRect()
{
return rect;
}
//Return image of element
QImage & player::getImage()
{
return image;
}
//Movement methods
void player::moveleft()
{
if (rect.left() > 15)
{
for (int i = 0; i < 16; i++)
rect.moveLeft(rect.left() - 1);
}
}
void player::moveright()
{
if (rect.right() < 983)
{
for (int i = 0; i < 16; i++)
rect.moveRight(rect.right() + 1);
}
}
void player::moveup()
{
if (rect.top() > 15)
{
for (int i = 0; i < 16; i++)
rect.moveTop(rect.top() - 1);
}
}
void player::movedown()
{
if (rect.bottom() < 733)
{
for (int i = 0; i < 16; i++)
rect.moveBottom(rect.bottom() + 1);
}
}
//Move player back to center upon death
void player::death()
{
rect.moveTo(500,375);
}