-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinglip.cpp
More file actions
92 lines (71 loc) · 1.06 KB
/
inglip.cpp
File metadata and controls
92 lines (71 loc) · 1.06 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
#include "inglip.h"
#include <iostream>
Inglip::Inglip()
{
xdir = 0;
ydir = -1;
image.load("imgs/CupcakeMoTransparent.gif");
rect = image.rect();
resetState();
}
Inglip::~Inglip()
{
}
void Inglip::moveLeft(int left)
{
if (rect.left() >= 2)
rect.moveTo(left, rect.top());
}
void Inglip::moveRight(int right)
{
if (rect.right() <= 690)
rect.moveTo(right, rect.top());
}
void Inglip::moveUp(int up)
{
if (rect.top() >= 2)
{
rect.moveTo(rect.left(),up);
}
}
void Inglip::moveDown(int down)
{
if (rect.bottom() <= 690)
rect.moveTo(rect.left(), down);
}
void Inglip::autoMove()
{
rect.translate(xdir, ydir);
if (rect.left() <= 0) {
xdir = 2;
}
if (rect.right() >= 690) {
xdir = -2;
}
if (rect.top() <= 100) {
ydir = 2;
}
if (rect.top() >= 690) {
ydir = -2;
}
}
void Inglip::resetState()
{
rect.moveTo(650, 550);
}
QRect Inglip::getRect()
{
return rect;
}
QImage & Inglip::getImage()
{
return image;
}
int Inglip::getXDir()
{
return xdir;
}
int Inglip::getYDir()
{
return ydir;
}