1 Star 1 Fork 0

youlj / Qt跑酷

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
barrier.cpp 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
youlj 提交于 2022-05-12 10:25 . 第一次提交
#include "barrier.h"
#include<QTime>
Barrier::Barrier(int x, int y, int width, int height)
:x{x},y{y},width{width},height{height}
{
}
Barrier::~Barrier()
{
}
Wall::Wall(int x, int y, int width, int height)
:Barrier{x,y,width,height}
{
qsrand(QTime::currentTime().msec());//设置随机种子
this->img.load(QString(wallImg).arg(qrand()%2+1));//随机加载wall1.png或者wall2.png
}
Attack::Attack(int x, int y, int width, int height)
:Barrier{x,y,width,height}
{
img.load(attckImg);
}
GreenBlood::GreenBlood(int x, int y, int width, int height)
:Barrier{x,y,width,height}
{
img.load(greenBloodBg);
}
Coin::Coin(int x, int y, int width, int height)
:Barrier{x,y,width,height}
{
for(int i=0;i<coinNumber;++i)
{
img[i].load(QString(coinImg).arg(i+1));
}
coinTimer.setInterval(coinInterval);
QObject::connect(&coinTimer,&QTimer::timeout,[this]()
{
currentCoin=(currentCoin+1)%coinNumber;
});
coinTimer.start();
}
Arrow::Arrow(int x, int y, int width, int height)
:Barrier{x,y,width,height}
{
img.load(arrowImg);
}
Blood::Blood(int x, int y, int width, int height)
:Barrier{x,y,width,height}
{
img.load(bloodBg);
}
C++
1
https://gitee.com/waterkiller/qt-parkour.git
git@gitee.com:waterkiller/qt-parkour.git
waterkiller
qt-parkour
Qt跑酷
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891