-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLifes.cpp
43 lines (39 loc) · 1.05 KB
/
Lifes.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
#include <QGraphicsObject>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QSize>
#include <QTimer>
#include <vector>
#include <iostream>
#include <stdlib.h>
#include "Lifes.h"
#include "Player.h"
Lifes::Lifes():QObject(), QGraphicsPixmapItem()
{
QPixmap img(":/imgs/3hearts.png");
setPixmap(img.scaled(QSize(150,50)));
setPos(110, 10);
QTimer * timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(wait()));
timer->start(100);
}
void Lifes::wait()
{
if(Player::lifes==3){
QPixmap img(":/imgs/3hearts.png");
setPixmap(img.scaled(QSize(150,50)));
setPos(150, 10);
}else if(Player::lifes==2){
QPixmap img(":/imgs/2hearts.png");
setPixmap(img.scaled(QSize(150,50)));
setPos(150, 10);
}else if(Player::lifes==1){
QPixmap img(":/imgs/1hearts.png");
setPixmap(img.scaled(QSize(150,50)));
setPos(150, 10);
}else{
QPixmap img(":/imgs/0hearts.png");
setPixmap(img.scaled(QSize(150,50)));
setPos(150, 10);
}
}