-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwall.cpp
More file actions
52 lines (45 loc) · 1.08 KB
/
Copy pathwall.cpp
File metadata and controls
52 lines (45 loc) · 1.08 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
#include"wall.h"
#include<QPainter>
#include<QDebug>
#include"constants.h"
Wall::Wall(qreal y,int type,GameController& controller):
controller(controller){
pos.setX(800);
pos.setY(y);
m_type=type;
move=false;
move_mode=false;
}
QRectF Wall::boundingRect() {
//墙宽20,给过的空间80
if(m_type){//下方墙
return QRectF(pos.x()-WIDTH/2,
pos.y()+DOOR/2,
WIDTH,320);
}
else{
return QRectF(pos.x()-WIDTH/2,pos.y()-DOOR/2-320,WIDTH,320);
}
}
void Wall::paint(QPainter &painter){
if(m_type){
painter.drawImage(boundingRect(),QImage(":/images/pipeu"));
}
else{
painter.drawImage(boundingRect(),QImage(":/images/piped"));
}
}
void Wall::advance(){
pos.setX(pos.x()-xspeed);
if(move){
if(pos.y()<120||pos.y()>350){
move_mode=!move_mode;
}
if(move_mode){
pos.setY(pos.y()+xspeed);
}
else{
pos.setY(pos.y()-xspeed);
}
}
}