-
Notifications
You must be signed in to change notification settings - Fork 0
/
Objet_bougeant.cpp
60 lines (45 loc) · 1.2 KB
/
Objet_bougeant.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
// CPE - 4ETI - Maj.Image - Programmation en C++ - 09/03/2018
// CARNEIRO ESTEVES, Sophie
// FOLETTO PIMENTA, Pedro
// TP 2
//includes
#include "Objet_bougeant.hpp"
Objet_bougeant::Objet_bougeant(): pixmap(new QPixmap)
{
//std::cout<<"Constructor of Objet_bougeant is called"<<std::endl;//debug
setPosition(0, 0);
}
Objet_bougeant::~Objet_bougeant()
{
//std::cout<<"Destructor of Objet_bougeant is called"<<std::endl;//debug
}
void Objet_bougeant::setPosition(int x, int y){
this->position = vec2(x,y);
}
void Objet_bougeant::setPosition(vec2 newPos){
this->position = newPos;
}
vec2 Objet_bougeant::getPosition(){
return this->position;
}
void Objet_bougeant::setSpeed(int x, int y){
this->speed = vec2(x,y);
}
void Objet_bougeant::setSpeed(vec2 newSpeed){
this->speed = newSpeed;
}
vec2 Objet_bougeant::getSpeed(){
return this->speed;
}
QPixmap* Objet_bougeant::getPixmap(){
return this->pixmap;
}
void Objet_bougeant::setPixmap(QPixmap* pixmap){
this->pixmap = pixmap;
}
void Objet_bougeant::loadImage(const char* imgName){
this->pixmap->load(imgName);
}
void Objet_bougeant::move(){
this->position = vec2(this->position.x+this->speed.x, this->position.y+this->speed.y);
}