-
Notifications
You must be signed in to change notification settings - Fork 0
/
penemyview.cpp
73 lines (68 loc) · 1.61 KB
/
penemyview.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
70
71
72
73
#include "penemyview.h"
#include <QTimer>
PEnemyView::PEnemyView()
{
setPixmap(QPixmap(":/images/P_1.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic = 4;
timer = new QTimer();
timerDeath = new QTimer();
connect(timer, SIGNAL(timeout()), this, SLOT(updates()));
connect(timerDeath, SIGNAL(timeout()), this, SLOT(updatesDeath()));
timer->start(120);
}
PEnemyView::~PEnemyView()
{
delete timerDeath;
delete timer;
}
void PEnemyView::updates()
{
switch (nrOfPic) {
case 1:{
setPixmap(QPixmap(":/images/P_1.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic=4;
break;
}
case 2:{
setPixmap(QPixmap(":/images/P_4.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic-=1;
break;
}
case 3:{
setPixmap(QPixmap(":/images/P_3.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic-=1;
break;
}
case 4:{
setPixmap(QPixmap(":/images/P_2.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic-=1;
break;
}
}
}
void PEnemyView::updatesDeath()
{
switch (nrOfPic) {
case 1:{
setPixmap(QPixmap(":/images/P_DEATH_1.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic=3;
break;
}
case 2:{
setPixmap(QPixmap(":/images/P_DEATH_3.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic-=1;
break;
}
case 3:{
setPixmap(QPixmap(":/images/P_DEATH_2.png").scaled(50,50,Qt::KeepAspectRatio));
nrOfPic-=1;
break;
}
}
}
void PEnemyView::dead_slot()
{
timer->stop();
nrOfPic = 3;
timerDeath->start(120);
}