-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrogger.cpp
69 lines (55 loc) · 1.3 KB
/
Frogger.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
#include "Frogger.h"
#include <iostream>
Frogger::Frogger()//Constructor
{
image.load(":/icons/images/Frogger.png");//sets the image of the frogger
rect = image.rect();
rect.setWidth(20);//sets the dimensions of the frogger
rect.setHeight(20);
}
Frogger::~Frogger()//Destructor.
{
}
int Frogger::getHeight()//returns the height of the object.
{
return rect.height();
}
int Frogger::getWidth()//returns the width of the object.
{
return rect.width();
}
void Frogger::moveLeft(int left)//moves one space to the left.
{
if (rect.left() >= 2)
rect.moveTo(left, rect.top());
}
void Frogger::moveRight(int right)//moves one space to the right.
{
if (rect.right() <= 398)
rect.moveTo(right, rect.top());
}
void Frogger::moveTop(int top)//moves one space to the top.
{
if (rect.top() >=32)
rect.moveTo(rect.left(), top);
}
void Frogger::moveBottom(int bottom)//moves one space to the bottom.
{
if(rect.bottom() <= 398)
rect.moveTo(rect.left(), bottom);
}
void Frogger::resetState()//resets the position of the frogger.
{
rect.moveTo(200, 360);
}
QRect Frogger::getRect() //returns the rect.
{
return rect;
}
QImage & Frogger::getImage() //returns the image.
{
return image;
}
void Frogger::movePositioning(int xcoordinate, int ycoordinate){
rect.moveTo(xcoordinate,ycoordinate);
}