Qt游戏开发-深海危机

2019-09-27 08:36:01 小生无名 阅读数 46更多

分类专栏: QT

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/cqltbe131421/article/details/101509539

#pragma execution_character_set("utf-8")
/*!@file    重庆予乔@author  陈强灵@date    2018/9@brief   软硬件定制开发@https   https://blog.csdn.net/cqltbe131421@verbatim<author>    <time>   <version>  <desc>    <QQ>chen 2018/9   0.1.0     build this module  609162385@endverbatim
*/
#ifndef COLORPOINT_H
#define COLORPOINT_H
#include <windows.h>
#include <QPointF>
#include <QRectF>
#include <QDebug>
#include <QColor>
#include <cmath>
#include <QPixmap>
class ColorPoint
{
private:QPointF m_point;//位置float radius;    //半径QColor m_color;float speed;bool is_bump;int score;QPixmap img;QPointF dir;int hp;
public:QRectF m_bound;ColorPoint();ColorPoint(QPointF point,int r, int sc=1);ColorPoint(QRectF bound);float getRadius() const;void setRadius(float value);QPointF getPoint() const;void setPoint(const QPointF &point);QColor getColor() const;void setColor(const QColor &color);float getSpeed() const;void setSpeed(float value);int getScore() const;void setScore(int value);bool getIs_bump() const;void setIs_bump(bool value);QPixmap getImg() const;void setImage(QString filename);int getHp() const;void setHp(int value);void lossHp(int value);QPointF getDir() const;void setDir(const QPointF &value);void setImg(const QPixmap &value);
};#endif // COLORPOINT_H
  • 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
#include "colorpoint.h"float ColorPoint::getRadius() const
{return radius;
}void ColorPoint::setRadius(float value)
{radius = value;float left  = m_point.x() - radius;float top   = m_point.y() - radius;m_bound.setRect(left,top,radius*2,radius*2);
}QPointF ColorPoint::getPoint() const
{return m_point;
}void ColorPoint::setPoint(const QPointF &point)
{m_point = point;float left  = m_point.x() - radius;float top   = m_point.y() - radius;m_bound.setRect(left,top,radius*2,radius*2);
}QColor ColorPoint::getColor() const
{return m_color;
}void ColorPoint::setColor(const QColor &color)
{m_color = color;
}float ColorPoint::getSpeed() const
{return speed;
}void ColorPoint::setSpeed(float value)
{speed = value;
}int ColorPoint::getScore() const
{return score;
}void ColorPoint::setScore(int value)
{score = value;
}bool ColorPoint::getIs_bump() const
{return is_bump;
}void ColorPoint::setIs_bump(bool value)
{is_bump = value;
}QPixmap ColorPoint::getImg() const
{return img;
}void ColorPoint::setImage(QString filename)
{img.load(filename);
}int ColorPoint::getHp() const
{return hp;
}void ColorPoint::setHp(int value)
{hp = value;
}void ColorPoint::lossHp(int value)
{hp-=value;
}QPointF ColorPoint::getDir() const
{return dir;
}void ColorPoint::setDir(const QPointF &value)
{dir = value;
}void ColorPoint::setImg(const QPixmap &value)
{img = value;
}ColorPoint::ColorPoint()
{}ColorPoint::ColorPoint(QPointF point, int r, int sc)
{m_point = point;radius = r;float left  = m_point.x() - radius;float top   = m_point.y() - radius;m_bound.setRect(left,top,radius*2,radius*2);speed = 10;score = sc;is_bump = false;m_color = QColor(0,0,0);hp =100;}ColorPoint::ColorPoint(QRectF bound)
{m_bound = bound;radius = m_bound.width();int radius2 = m_bound.height();m_point = QPoint(m_bound.x()+radius,m_bound.y()+radius2);speed = 10;score = 1;is_bump = false;m_color = QColor(0,0,0);hp = 100;
}
  • 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
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
#pragma execution_character_set("utf-8")
/*!@file    重庆予乔@author  陈强灵@date    2018/9@brief   软硬件定制开发@https   https://blog.csdn.net/cqltbe131421@verbatim<author>    <time>   <version>  <desc>    <QQ>chen 2018/9   0.1.0     build this module  609162385@endverbatim
*/
#ifndef INTRAWINDOW_H
#define INTRAWINDOW_H
#include <windows.h>
#include <QWidget>
#include <QPainter>
#include <QPaintEvent>
#include <QImage>
#include <QDesktopWidget>
namespace Ui {
class IntraWindow;
}class IntraWindow : public QWidget
{Q_OBJECTpublic:explicit IntraWindow(QWidget *parent = 0);QImage backImage;~IntraWindow();void paintEvent(QPaintEvent*e);private slots:void on_pushButton_3_clicked();private:Ui::IntraWindow *ui;
};#endif // INTRAWINDOW_H
  • 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 "intrawindow.h"
#include "ui_intrawindow.h"
#include <QColor>
#include <QFile>
#include <QTextStream>
#include <qDebug>IntraWindow::IntraWindow(QWidget *parent) :QWidget(parent),ui(new Ui::IntraWindow)
{ui->setupUi(this);ui->textEdit->setTextColor(QColor(255,255,255));QFile f(":/image/image/Intra.txt");if(!f.open(QIODevice::ReadOnly | QIODevice::Text)){qDebug()<<"Open failed.";}//获取设备屏幕大小QDesktopWidget* desktopWidget = QApplication::desktop();QRect screenRect = desktopWidget->screenGeometry();int w = screenRect.width();int h = screenRect.height();this->setGeometry(w/3,h/3,w/3,h/3);w = this->width();h = this->height();QTextStream txtInput(&f);QString lineStr = "";while(!txtInput.atEnd()){lineStr = lineStr+txtInput.readLine();lineStr = lineStr+'\n';//qDebug()<<lineStr;}this->setWindowFlags(Qt::FramelessWindowHint);ui->textEdit->setText(lineStr);backImage.load(":/image/image/b1.jpg");ui->textEdit->setGeometry(w/10,h/10,w/10*8,h/10*7);ui->pushButton_3->setGeometry(w/5*2,h/5*4+h/15,w/5,h/10);ui->textEdit->setReadOnly(true);ui->textEdit->setFontItalic(true);
//    ui->textEdit->setTextColor(QColor(0,0,0));}IntraWindow::~IntraWindow()
{delete ui;
}void IntraWindow::paintEvent(QPaintEvent *e)
{QPainter paint(this);paint.drawImage(this->rect(),backImage);
}void IntraWindow::on_pushButton_3_clicked()
{this->close();
}
  • 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "widget.h"
#include <QMovie>
#include <qDebug>
#include <QTimer>
#include <QPropertyAnimation>int MainWindow::n = 1;MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{ui->setupUi(this);// this->setGeometry(0,0,1000,1000);this->setWindowFlags(Qt::FramelessWindowHint);
backImage.load(":/image/image/b1.jpg");
QDesktopWidget* desktopWidget = QApplication::desktop();//获取设备屏幕大小
QRect screenRect = desktopWidget->screenGeometry();
int w = screenRect.width();
int h = screenRect.height();
this->setGeometry(w/3,h/3,w/3,h/3);
w = this->width();
h = this->height();
int bw = w/5;
int bh = h/15;
int dist = h/25;
ui->pushButton->setGeometry(w-bw-dist,h-(bh+dist)*3,bw,bh );
ui->pushButton_3->setGeometry(w-bw-dist,h-(bh+dist)*2,bw,bh );
ui->pushButton_2->setGeometry(w-bw-dist,h-(bh+dist)*1,bw,bh );logo = QPixmap(QString(":/image/image/b2.png"));
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::paintEvent(QPaintEvent *e)
{QPainter paint(this);paint.drawImage(this->rect(),backImage);paint.drawPixmap(QRect(0,this->height()/4,this->width(),this->height()/4*2),logo,logo.rect());}void MainWindow::btn()
{if(MainWindow::n){Widget *w  = new Widget();this->setCentralWidget(w);QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");animation->setDuration(3000);animation->setStartValue(0);animation->setEndValue(1);animation->start();n-=1;}
}void MainWindow::on_pushButton_2_clicked()
{this->close();
}void MainWindow::on_pushButton_3_clicked()
{Widget *m_widget = new Widget();m_widget->show();
}void MainWindow::on_pushButton_clicked()
{IntraWindow *w = new IntraWindow();w->show();
}
  • 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
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <windows.h>
#include <QMainWindow>
#include "widget.h"
#include "intrawindow.h"
namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{Q_OBJECTpublic:explicit MainWindow(QWidget *parent = 0);~MainWindow();QImage backImage;void paintEvent(QPaintEvent*e);QPixmap logo;
public slots:void btn();private slots:void on_pushButton_2_clicked();void on_pushButton_3_clicked();void on_pushButton_clicked();private:Ui::MainWindow *ui;static int n;
};#endif // MAINWINDOW_H
  • 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
#include "widget.h"
#include "ui_widget.h"
#include "quadtree.h"Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{ui->setupUi(this);this->setWindowTitle(QString("深海危机 1.0v"));QDesktopWidget* desktopWidget = QApplication::desktop();//获取设备屏幕大小QRect screenRect = desktopWidget->screenGeometry();int x = screenRect.width();int y = screenRect.height();this->setGeometry(100,100,x-200,y-200);this->setFixedSize(x-200,y-200);ui->depthbox->setGeometry(this->width()-150,this->height()/4,100,80);ui->depthbox->hide();ui->disbumpbtn->setGeometry(this->width()-180,this->height()-300,100,100);ui->disbumpbtn->hide();ui->background_label->setGeometry(0,0,this->width(),this->height());//初始化条件backImage.load(":/image/image/b1.jpg");//     backImage.load(":/image/image/海底阳光.gif");for(int i =1;i<= 8; i++){imglist.push_back(QPixmap(QString(":/image/image/%1.png").arg(i)));}for(int i =0;i< 34; i++){backimglist.push_back(QPixmap(QString(":/image/back/back %1.png").arg(i)));}playerBack = new QMediaPlayer;playlist = new QMediaPlaylist;backMusicName = "./music/buildMusic.mp3";beginBackMusic();shootImage.load(":/image/image/shoot.png");depth = 0;qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));this->setMouseTracking(true);//计时器的使用realtimer = new QTimer(this);connect(realtimer,SIGNAL(timeout()),this,SLOT(realAct()));connect(realtimer,SIGNAL(timeout()),this,SLOT(army_move()));gentimer = new QTimer(this);connect(gentimer,SIGNAL(timeout()),this,SLOT(generatePoints()));gametimer = new QTimer(this);connect(gametimer,SIGNAL(timeout()),this,SLOT(change_remaintime()));pushtimer = new QTimer(this);connect(pushtimer,SIGNAL(timeout()),this,SLOT(push_Animaltime()));newBegin();}Widget::~Widget()
{delete ui;
}
void Widget::paintEvent(QPaintEvent *e)
{QPainter paint(this);QFont font ;paint.setBrush(QColor(0,0,0));// m_player->setColor(QColor(0,100,0));paint.drawImage(this->rect(),backImage);paint.setOpacity(0.2);paint.drawPixmap(QRect(0,0,this->width(),this->height()),backimglist[backIndex],backimglist[backIndex].rect());paint.setOpacity(1);playerBump();paint.setPen(QColor(0,0,255));int test_count = 0;int total_count = 0;for( int i = 0; i< pointList.size(); i++){paint.drawPixmap(pointList[i]->m_bound,pointList[i]->getImg(),pointList[i]->getImg().rect());}for( int i = 0; i< shootList.size(); i++){paint.drawPixmap(shootList[i]->m_bound,shootImage,shootImage.rect());}//绘制玩家paint.setBrush(m_player->getColor());//    paint.drawEllipse(m_player->m_bound);paint.drawPixmap(m_player->m_bound,m_player->getImg(),m_player->getImg().rect());font.setPointSize((int)m_player->getRadius()/2);paint.setFont(font);paint.setPen(QColor(255,255,255));QPointF m_point = m_player->getPoint();m_point.setX(m_point.x() -m_player->getRadius()/2);m_point.setY(m_point.y() +m_player->getRadius()/2);paint.setPen(QColor(0,0,255));font.setPointSize(10);font.setBold(true);paint.setFont(font);drawPushWidgt(paint,push_x);// paint.drawRect((int)m_tree.getHeadBound().width()/2,0,1,(int)m_tree.getHeadBound().height());//  paint.drawRect(0,(int)m_tree.getHeadBound().height()/2,(int)m_tree.getHeadBound().width(),1);font.setPointSize(15);paint.setFont(font);paint.setPen(QColor(0,0,0));//    paint.drawText(bx,700,QString("得分"));//    paint.drawText(bx,750,QString(" %1").arg(m_socre));paint.drawText(this->width()/5*2,40,QString("当前耗时: "));paint.setPen(QColor(255,0,0));paint.drawText(this->width()/5*2,40,QString("         %1").arg(remaintime));paint.setPen(QColor(0,0,0));paint.drawText(this->width()/5*3,40,QString("得分:"));paint.setPen(QColor(0,255,0));paint.drawText(this->width()/5*3,40,QString("      %1").arg(m_socre));if(m_player->getHp()==-10){//        realAct();gameover();//        ui->progressBar->setValue(0);QPixmap pushwidget(this->width(),this->height());pushwidget.fill(Qt::black);paint.setOpacity(0.5);paint.drawPixmap(QRect(0,0,this->width(),this->height()),pushwidget,pushwidget.rect());paint.setOpacity(1);}}void Widget::quadTest()
{int find_count = 0;QuadNode *tp = m_tree.getHead();QQueue<QuadNode*> node;node.enqueue(tp);while(node.size()!=0){QuadNode* p = node.dequeue();for( int k = 0; k< p->pointList.size();k++){if(p->pointList[k]->getIs_bump() == true)continue;QList<ColorPoint*> found = pointList;find_count +=found.size();for( int i = 0; i< found.size(); i++){if( found[i]->getPoint() != p->pointList[k]->getPoint())//if(fabs(fx-px)> 0.1&& fabs(fy-py)>0.1 ){QPointF p1 = found[i]->getPoint();QPointF p2 = p->pointList[k]->getPoint();float l = found[i]->getRadius()+p->pointList[k]->getRadius();float len =l*l;  //半径和的平方float dx = p1.x() - p2.x();float dy = p1.y() - p2.y();float dist = dx*dx + dy*dy;//圆心距if(len >= dist){//p->pointList[k]->setColor(QColor(200,0,0));p->pointList[k]->setIs_bump(true);found[i]->setIs_bump(true);}}}}for( int i = 0; i< 4; i++){if(p->child[i] != NULL){node.enqueue(p->child[i]);}}}qDebug()<<"四叉检测次数"<<find_count;
}void Widget::playerBump()
{int num = 0;QList<ColorPoint*> found = pointList;for( int i = 0; i< found.size(); i++){if( found[i]->getPoint() != m_player->getPoint()){QPointF p1 = found[i]->getPoint();QPointF p2 = m_player->getPoint();float l = found[i]->getRadius()+m_player->getRadius();float len =l*l;  //半径和的平方float dx = p1.x() - p2.x();float dy = p1.y() - p2.y();float dist = dx*dx + dy*dy;//圆心距if(len > dist){m_player->setColor(found[i]->getColor());//                m_tree.remove(found[i]);pointList.removeAt(i);num++;//                m_socre+=found[i]->getScore();}}}if(num>0){m_player->lossHp(10);}//    m_player->setRadius(m_player->getRadius()+0.15*num);//    if(m_player->getSpeed() > 5)//    {//        m_player->setSpeed(m_player->getSpeed() - 0.01*num );//    }//检测敌人碰撞num = 0;for( int j =0; j< shootList.size(); j++){m_army = shootList[j];found = pointList;for( int i = 0; i< found.size(); i++){if( found[i]->getPoint() != m_army->getPoint()){QPointF p1 = found[i]->getPoint();QPointF p2 = m_army->getPoint();float l = found[i]->getRadius()+m_army->getRadius();float len =l*l;  //半径和的平方float dx = p1.x() - p2.x();float dy = p1.y() - p2.y();float dist = dx*dx + dy*dy;//圆心距if(len >= dist+0.01){//                        m_army->setColor(found[i]->getColor());//                        m_tree.remove(found[i]);num++;pointList.removeAt(i);shootList.removeAt(j);i--;break;}}}}m_socre+= num*10;//        m_army->setRadius(m_army->getRadius()+0.15*num);//        if(m_army->getSpeed() > 5)//        {//            m_army->setSpeed(m_army->getSpeed() - 0.01*num );//        }//        //判断和敌人是否相撞//        QPointF p1 = m_player->getPoint();//        QPointF p2 = m_army->getPoint();//        float l = m_army->getRadius()+m_player->getRadius();//        float len =l*l;  //半径和的平方//        float dx = p1.x() - p2.x();//        float dy = p1.y() - p2.y();//        float dist = dx*dx + dy*dy;//圆心距//        if(len >= dist)//        {//            if(m_army->getRadius() >= m_player->getRadius())//            {//                remaintime = 0;//            }else//            {//                m_player->setScore(m_player->getScore()+m_army->getScore());//                int x = qrand()%(int)(m_tree.getHeadBound().width() -40)+20+m_tree.getHeadBound().x();//                int y = qrand()%(int)(m_tree.getHeadBound().height()-40)+20+m_tree.getHeadBound().y();//                m_army = new ColorPoint(QPointF(x,y),35);//                armys.remove(i);//                armys.push_back(m_army);//            }//        }//    }}void Widget::gameover()
{gametimer->stop();realtimer->stop();gentimer->stop();// ui->disbumpbtn->setEnabled(false);
}void Widget::newBegin()
{shootList.clear();pointList.clear();gametimer->stop();realtimer->stop();gentimer->stop();ui->pushButton->setGeometry(this->width()/4*3,this->height()/3,20,this->height()/3);ui->beginButton->setGeometry(this->width()/16*13,this->height()/5*4,this->width()/16*2,this->height()/25);ui->beginButton->hide();ui->progressBar->setGeometry(50,20,this->width()/4,20);is_move = false;m_socre = 0;backIndex = 0;shootType = 0;remaintime = 0;m_count =0;is_disbump = false;is_push = true;is_pushwin = true;shootRadius =20;push_x = this->width()/4-20;
//    backImage.load(":/image/image/first.jpg");m_tree.setHeadBound(QRectF(100,100,this->width()-300,this->height()-150));m_player = new ColorPoint(QPointF(800,700),this->width()/50);m_player->setImage(":/image/image/fish.png");cur_pos.setX(m_player->getPoint().x());cur_pos.setY(m_player->getPoint().y());ui->progressBar->setValue(m_player->getHp());ui->progressBar->setStyleSheet("QProgressBar::chunk {""background-color:   #00FF00;""text-align: center;""width: 20px;}"" QProgressBar {""  border: 2px solid grey;"" border-radius: 5px;""  text-align: center;""}");buildPoint(20);update();}void Widget::initShoot(int num)
{//    m_army = new ColorPoint(QPointF(500,600),20);//        shootList.clear();//        for( int i = 0; i< num; i++)//        {//            int x = qrand()%(int)(m_tree.getHeadBound().width() -40)+20+m_tree.getHeadBound().x();//            int y = qrand()%(int)(m_tree.getHeadBound().height()-40)+20+m_tree.getHeadBound().y();//            ColorPoint* shoot = new ColorPoint(QPointF(x,y),20);//            armys.push_back(shoot);//        }
}void Widget::drawPushWidgt(QPainter &paint, int w)
{int h = this->height();int rx = this->width()-w;QPixmap pushwidget(w,this->height()/3);pushwidget.fill(Qt::white);paint.setOpacity(0.5);paint.drawPixmap(QRect(rx,h/3,rx,h/3),pushwidget,pushwidget.rect());paint.setOpacity(1);int bx=rx+w/4;int dist_h = h/3/8;paint.setPen(QColor(0,0,0));QFont font;font.setBold(true);font.setFamily("微软雅黑");paint.drawText(bx,h/3+dist_h*1,QString("移动: 鼠标控制"));paint.drawText(bx,h/3+dist_h*2,QString("切换攻击模式: T"));paint.drawText(bx,h/3+dist_h*3,QString("加/减攻击范围: W/S"));paint.drawText(bx,h/3+dist_h*4,QString("开始/暂停游戏: 右击"));paint.drawText(bx,h/3+dist_h*5,QString("退出游戏:ESC"));paint.drawText(bx,h/3+dist_h*6,QString("重置游戏: B"));paint.setPen(QColor(255,0,0));paint.drawText(bx,h/3+dist_h*7,QString("开始游戏请点击鼠标右键"));}void Widget::beginBackMusic()
{playlist->addMedia(QUrl::fromLocalFile("./music/backMusic.mp3"));playlist->setCurrentIndex(1);playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);playerBack->setPlaylist(playlist);playerBack->setVolume(20);playerBack->play();
}
void Widget::buildPoint(int number)
{//    pointList.clear();//    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));//qsrand(1);for( int i = 0; i< number; i++){int x = qrand()%(int)(m_tree.getHeadBound().width() -40)+20+m_tree.getHeadBound().x();int y = qrand()%(int)(m_tree.getHeadBound().height()-40)+20+m_tree.getHeadBound().y();int r = qrand()%255;int g = qrand()%255;int b = qrand()%255;int d = this->width()/100;float radius = qrand()%d+d;ColorPoint *point = new ColorPoint(QPointF(x,y),radius);point->setImg(imglist[qrand()%8]);point->setColor(QColor(r,g,b));pointList.push_back(point);//        m_tree.insert(point);}qDebug()<<"小球总数:"<< m_tree.size();int find_count = 0;//    for( int i = 0; i< pointList.size(); i++)//    {//        for( int j = 0; j< pointList.size();j++)//        {//            QPointF p1 = pointList[i]->getPoint();//            QPointF p2 = pointList[j]->getPoint();//            if(p1!=p2){//                float l = pointList[i]->getRadius()+pointList[j]->getRadius();//                float len =l*l;  //半径和的平方//                float dx = p1.x() - p2.x();//                float dy = p1.y() - p2.y();//                float dist = dx*dx + dy*dy;//圆心距//                if(len >= dist)//                {//                    pointList[i]->setIs_bump(true);//                }//            }//            find_count++;//        }//    }int bump = 0;for( int i = 0; i< pointList.size(); i++)if(pointList[i]->getIs_bump() == true)bump++;qDebug()<<"非四叉树检测次数"<<find_count;qDebug()<<"碰撞个数"<<bump;//    m_tree.initBump();//    quadTest();}void Widget::on_depthbox_valueChanged(int arg1)
{depth = arg1;update();
}void Widget::generatePoints()
{//qsrand(1);int x = qrand()%(int)(m_tree.getHeadBound().width() -40)+20+m_tree.getHeadBound().x();int y = qrand()%(int)(m_tree.getHeadBound().height()-40)+20+m_tree.getHeadBound().y();QPointF m_point = m_player->getPoint();float mx = m_point.x();float my = m_point.y();float dx = mx-x;float dy = my-y;float dist = sqrt(dx*dx+dy*dy);int d = this->width()/100;float radius = qrand()%d+d;if( dist< radius+m_player->getRadius())return;int r = qrand()%255;int g = qrand()%255;int b = qrand()%255;ColorPoint *point = new ColorPoint(QPointF(x,y),radius);point->setColor(QColor(r,g,b));point->setImg(imglist[qrand()%8]);//    m_tree.insert(point);//    m_tree.initBump();pointList.push_back(point);//    quadTest();//update();}
void Widget::resizeEvent(QResizeEvent *)
{int w = this->width();int h = this->height();ui->pushButton->setGeometry(this->width()/4*3,this->height()/3,20,this->height()/3);ui->beginButton->setGeometry(this->width()/16*13,this->height()/5*4,this->width()/16*2,this->height()/25);ui->beginButton->hide();ui->progressBar->setGeometry(50,20,this->width()/4,20);update();}
void Widget::realAct()
{backIndex++;backIndex = backIndex%backimglist.size();if(m_player->getHp()==0){ui->progressBar->setValue(0);m_player->lossHp(10);QString str ="游戏结束!\n";is_pushwin = false;str+= QString(QString("最终得分: %1 ").arg(m_socre)+"\n");str+=QString("是否重新开始?\nyes继续游戏,No退出游戏");QMessageBox message(QMessageBox::NoIcon, "游戏结束", str,QMessageBox::Yes | QMessageBox::No, NULL);message.setIconPixmap(m_player->getImg().scaled(100,100));if(message.exec() == QMessageBox::Yes){newBegin();//                pushtimer->start(15);}else {this->close();}}if( is_move == true){for( int i =0; i< shootList.size(); i++){shootList[i]->setPoint(shootList[i]->getDir()*50 +shootList[i]->getPoint());}float dist = m_player->getSpeed();QPointF m_point = m_player->getPoint();float dx = cur_pos.x() - m_point.x();float dy = cur_pos.y() - m_point.y();//        if(fabs(dx)<m_player->getRadius() &&fabs(dy) <m_player->getRadius())//        {//            is_move == false;//            //update();//            return;//        }if(fabs(dx) <= m_player->getRadius()*1 ){if(dy > 0)m_point.setY(m_point.y()+dist);elsem_point.setY(m_point.y()-dist);if(m_point.y() - m_player->getRadius() <100  )return;m_player->setPoint(m_point);if(dx<0)m_player->setImage(":/image/image/fish.png");elsem_player->setImage(":/image/image/fish_right.png");ui->progressBar->setValue(m_player->getHp());update();return;}//        if(dx == 0){//            return;//        }float k = dy/(dx+0.00001);int x;float p_dist = sqrt(dx*dx+dy*dy);int d = (int)p_dist/dist;{x = dx/d;float fx = k*x;m_point.setX(m_point.x()+x);m_point.setY(m_point.y()+fx);if(m_point.x() + m_player->getRadius() -100 > m_tree.getHeadBound().width() )return;if(m_point.y() - m_player->getRadius() <100  )return;if(dx<0)m_player->setImage(":/image/image/fish.png");elsem_player->setImage(":/image/image/fish_right.png");m_player->setPoint(m_point);}}
//    if(m_count%3==0){//    }if(m_count%2==0&& shootType == 1){ColorPoint *p = new ColorPoint(m_player->getPoint(),shootRadius);QPointF m_point = m_player->getPoint();float dx = cur_pos.x() - m_point.x();float dy = cur_pos.y() - m_point.y();p->setDir((cur_pos-m_player->getPoint())/sqrt(dx*dx+dy*dy)/2);shootList.push_back(p);}if(m_count%10==0&& shootType == 0){ColorPoint *p = new ColorPoint(m_player->getPoint(),shootRadius);QPointF m_point = m_player->getPoint();float dx = cur_pos.x() - m_point.x();float dy = cur_pos.y() - m_point.y();p->setDir((cur_pos-m_player->getPoint())/sqrt(dx*dx+dy*dy)/2);shootList.push_back(p);}for( int i =0; i< shootList.size(); i++){if(!m_tree.getHeadBound().contains(shootList[i]->getPoint()))shootList.removeAt(i);}ui->progressBar->setValue(m_player->getHp());m_count++;update();}
void Widget::mousePressEvent(QMouseEvent *e)
{if(e->button() == Qt::RightButton && m_player->getHp()>0){//        m_player->setPoint(e->pos());//        is_move = false;//        update();if(push_x <this->width()/4-20 && push_x>20)return;if(gametimer->isActive()){gametimer->stop();gentimer->stop();realtimer->stop();pushtimer->start(15);}else {is_move = true;gametimer->start(1000);gentimer->start(300);realtimer->start(30);pushtimer->start(15);}}if(e->button() == Qt::LeftButton){// cur_pos = e->pos();//        is_move = true;//        gametimer->start(1000);//        gentimer->start(1000);//        realtimer->start(100);}update();}void Widget::mouseMoveEvent(QMouseEvent *e)
{cur_pos = e->pos();
}void Widget::keyPressEvent(QKeyEvent *e)
{if(e->key() == Qt::Key_Escape)this->close();if(e->key() == Qt::Key_B){newBegin();}if(e->key() == Qt::Key_W){for( int i = 0; i< shootList.size();i++){shootRadius+=1;if(shootRadius>50)shootRadius =50;}}if(e->key() == Qt::Key_S){shootRadius-=1;if(shootRadius<10)shootRadius =10;}if(e->key() == Qt::Key_T){if(shootType == 0)shootType = 1;elseshootType = 0;qDebug()<<"change shootType";}}void Widget::on_disbumpbtn_clicked()
{is_disbump = !is_disbump;if(is_disbump == true){//quadTest();ui->disbumpbtn->setText(QString("不检测"));}elseui->disbumpbtn->setText(QString("检测"));update();}void Widget::change_remaintime()
{remaintime++;}void Widget::army_move()
{//敌人随机运动//    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));for( int i = 0; i< pointList.size();i++){QPointF dxy = pointList[i]->getPoint() - m_player->getPoint();dxy/=150;pointList[i]->setPoint( pointList[i]->getPoint()- dxy);QRectF dBound(pointList[i]->m_bound.x()-dxy.x(),pointList[i]->m_bound.y()-dxy.y(),pointList[i]->m_bound.width(),pointList[i]->m_bound.height()) ;pointList[i]->m_bound=dBound;//        pointList[i]->setRadius(pointList[i]->getRadius()+0.1);}update();
}void Widget::on_pushButton_clicked()
{//    bool x = is_push;//    pushtimer->start(15);//    if(x == true){//    is_move = true;//    gametimer->start(1000);//    gentimer->start(1000);//    realtimer->start(100);//    }if( m_player->getHp()>0){//        m_player->setPoint(e->pos());//        is_move = false;//        update();//        if(gametimer->isActive()){//            gametimer->stop();//            gentimer->stop();//            realtimer->stop();//            pushtimer->start(15);//        }else {//            is_move = true;//            gametimer->start(1000);//            gentimer->start(1000);//            realtimer->start(100);//            pushtimer->start(15);//        }}}void Widget::push_Animaltime()
{int h = this->height();if(is_push == true){push_x-=this->width()/150;ui->pushButton->setGeometry(this->width()-20-push_x,h/3,20,h/3);if(push_x<=0){ui->pushButton->setText(QString("←"));is_push = !is_push;pushtimer->stop();}}else{push_x+=this->width()/150;ui->pushButton->setGeometry(this->width()-20-push_x,h/3,20,h/3);if(push_x>=this->width()/4-20){ui->pushButton->setText(QString("→"));is_push = !is_push;pushtimer->stop();}}update();
}void Widget::on_progressBar_valueChanged(int value)
{if(value<=30)ui->progressBar->setStyleSheet("QProgressBar::chunk {""background-color: #FF0000;""width: 20px;}"" QProgressBar {""  border: 2px solid grey;"" border-radius: 5px;""  text-align: center;""}");if(value>30&& value<70)ui->progressBar->setStyleSheet("QProgressBar::chunk {""background-color:  #FFFF00;""text-align: center;""width: 20px;}"" QProgressBar {""  border: 2px solid grey;"" border-radius: 5px;""  text-align: center;""}");if(value>=70)ui->progressBar->setStyleSheet("QProgressBar::chunk {""background-color:   #00FF00;""text-align: center;""width: 20px;}"" QProgressBar {""  border: 2px solid grey;"" border-radius: 5px;""  text-align: center;""}");
}void Widget::on_beginButton_clicked()
{}
  • 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
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
  • 704
  • 705
  • 706
  • 707
  • 708
  • 709
  • 710
  • 711
  • 712
  • 713
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • 724
  • 725
  • 726
  • 727
  • 728
  • 729
  • 730
  • 731
  • 732
  • 733
  • 734
  • 735
  • 736
  • 737
  • 738
  • 739
  • 740
  • 741
  • 742
  • 743
  • 744
  • 745
  • 746
  • 747
  • 748
  • 749
  • 750
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • 761
  • 762
  • 763
  • 764
  • 765
  • 766
  • 767
  • 768
  • 769
  • 770
  • 771
  • 772
  • 773
  • 774
  • 775
  • 776
  • 777
  • 778
  • 779
  • 780
  • 781
  • 782
  • 783
  • 784
  • 785
  • 786
  • 787
  • 788
  • 789
  • 790
  • 791
  • 792
  • 793
  • 794
  • 795
  • 796
  • 797
  • 798
  • 799
  • 800
  • 801
  • 802
  • 803
  • 804
  • 805
  • 806
  • 807
  • 808
  • 809
  • 810
  • 811
  • 812
  • 813
  • 814
  • 815
  • 816
  • 817
  • 818
  • 819
  • 820
  • 821
  • 822
  • 823
  • 824
  • 825
  • 826
  • 827
  • 828
  • 829
  • 830
  • 831
  • 832
  • 833
  • 834
  • 835
  • 836
  • 837
  • 838
  • 839
  • 840
  • 841
  • 842
  • 843
  • 844
  • 845
  • 846
  • 847
  • 848
  • 849
  • 850
  • 851
  • 852
  • 853
  • 854
  • 855
  • 856
  • 857
  • 858
  • 859
  • 860
  • 861
#ifndef WIDGET_H
#define WIDGET_H
#include <windows.h>
#include <QWidget>
#include <quadnode.h>
#include "quadtree.h"
#include <QVector>
#include <QPainter>
#include <QPaintEvent>
#include <QDebug>
#include <QtGlobal>
#include <QTime>
#include <QMoveEvent>
#include <QKeyEvent>
#include <QTimer>
#include <QFont>
#include <QRadialGradient>
#include <QBrush>
#include <QList>
#include <QImage>
#include <QDesktopWidget>
#include <QMessageBox>
#include <QResizeEvent>
#include <cmath>
#include <QSplashScreen>
#include <QLabel>
#include <QMovie>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <synchapi.h>
#include <QPixmap>
namespace Ui {
class Widget;
}class Widget : public QWidget
{Q_OBJECT
private:QuadTree m_tree;int depth;QList<ColorPoint*> pointList;QList<ColorPoint*> shootList;ColorPoint *m_player,*m_army;QList<ColorPoint* >armys;int m_socre;//float dir;QPoint cur_pos;   //鼠标当前位置bool is_move;     //球是否处于移动状态bool is_disbump;  //是否着重显示碰撞的小球bool is_push;   //判断是否拉开int remaintime;int m_count;bool is_pushwin;int shootType;QTimer *realtimer; //控制球移动的计时器QTimer *gentimer;  //生成球的计时器QTimer *gametimer; //游戏倒计时QTimer *pushtimer; //状态栏动画QImage backImage;int push_x;float shootRadius;QVector<QPixmap> imglist;QVector<QPixmap> backimglist;int backIndex;QPixmap shootImage;void buildPoint(int number);QMediaPlayer *playerBack;//背景音乐播放器对象QString backMusicName;//背景音乐名称QMediaPlaylist *playlist;
public:explicit Widget(QWidget *parent = 0);void paintEvent(QPaintEvent*e);void mousePressEvent(QMouseEvent *e);void mouseMoveEvent(QMouseEvent *e);void keyPressEvent(QKeyEvent*e);void resizeEvent(QResizeEvent *);void quadTest();void playerBump();void gameover();void newBegin();void initShoot(int num);void drawPushWidgt(QPainter & paint,int w);void beginBackMusic();~Widget();private slots:void on_depthbox_valueChanged(int arg1);void generatePoints();void realAct();void on_disbumpbtn_clicked();void change_remaintime();void army_move();void on_pushButton_clicked();void push_Animaltime();void on_progressBar_valueChanged(int value);void on_beginButton_clicked();private:Ui::Widget *ui;
};#endif // WIDGET_H
  • 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
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108

Qt游戏开发-深海危机相关推荐

  1. Qt会场触摸互动开发,超大屏触摸游戏开发

    Qt会场互动触摸屏幕 Qt会场触摸屏幕开发,可以转换成触摸游戏开发等, 可以将任意墙壁,任意平面进行转换成点击事件. #include "qtantanscanning.h" #i ...

  2. 添加类iOS cocos2d 2游戏开发实战(第3版)

    这两天一直在学习添加类之类的问题,现在正好有机会和大家讨论一下. 第1章 简介 1 1.1 第3版中的新增内容 2 1.2 选择ios版cocos2d的来由 3 1.2.1 收费 3 1.2.2 开源 ...

  3. Qt界面开发(各种控件以及图表)

    Qt界面开发(各种控件以及图表) 1.Qt简洁窗体 源代码链接:点击打开链接 2.QT漂亮界面 源代码链接:点击打开链接 3.音乐播放器界面 源代码链接:点击打开链接 4.六宫格界面 源代码链接:点击 ...

  4. 《Android 游戏开发大全(第二版)》——6.4节角色扮演游戏

    本节书摘来自异步社区<Android 游戏开发大全(第二版)>一书中的第6章,第6.4节角色扮演游戏,作者吴亚峰 , 于复兴 , 杜化美,更多章节内容可以访问云栖社区"异步社区& ...

  5. 【Visual C++】游戏开发笔记十九 DirectX与OpenGL的博弈

    From: http://blog.csdn.net/zhmxy555/article/details/7522960 本系列文章由zhmxy555(毛星云)编写,转载请注明出处. http://bl ...

  6. 【Visual C++】游戏开发笔记三十四 浅墨DirectX提高班之三 起承转合的艺术:Direct3D渲染五步曲...

    本系列文章由zhmxy555(毛星云)编写,转载请注明出处. 文章链接: http://blog.csdn.net/zhmxy555/article/details/8223965 作者:毛星云(浅墨 ...

  7. 【Visual C 】游戏开发笔记三十四 浅墨DirectX提高班之三 起承转合的艺术 Direct3D渲染五步曲

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 本系列文 ...

  8. 【Qt设计开发】GUI界面设计开发

    文章目录 一.Qt简介和下载安装 二.Qt入门 2.1 创建第一个项目 2.2 快捷键和命名规范 2.3 Qt项目和VS2022项目相互转换 三.Qt基础 3.1 Qt对象树和窗口坐标系概念 3.2 ...

  9. 2020秋招 C++软件开发/游戏开发 面试知识整理汇总

    鄙人的2020秋招目前已经基本结束,最终拿了六家公司的offer,在综合比较之后目前已经有了明确的偏向,那就是去某公司转行Java,至于原因有很多层,我即使在做了这个决定半年后还是不敢肯定这个决定是否 ...

最新文章

  1. Leetcode1713. 得到子序列的最少操作次数[C++题解]:LCS转化成LIS,转化为nlogn做法
  2. 机器学习算法加强——XGBoost实践
  3. Python爬虫开发:cookie的使用案例
  4. des加密去掉特殊字符_对称加密中的数据填充
  5. [原创] nunit2report V1.2.2 release 汉化修正版 V1.0
  6. android 获取已安装 错误代码,android获取手机已经安装的app信息
  7. dw2019连接mysql数据库_Dreamweaver 8.0连接Mysql数据库全攻略
  8. 「CJOJ2723」Reserve
  9. 前端实现序列帧_canvas实现序列帧动画的案例
  10. MES系统是什么?MES系统的主要功能是什么?看完本文就知道
  11. OpenGL采样贴图显示不出来
  12. php hprose扩展1.5.5,Laravel框架RPC解决方案--Hprose
  13. 龙格-库塔(Runge-Kutta)方法C++实现
  14. 使用freessl免费证书
  15. 机器学习应用——导学part
  16. 超好用的UWP应用推荐
  17. 评估分形指数和HURST指数预测金融时间序列的能力
  18. (原创)报考计算机博士之前应该注意的几个问题---写给应届硕士毕业生
  19. @开发者:个推小程序消息推送解决方案来了
  20. 红米1联通版_标注:2013023_官方线刷包_救砖包_解账户锁

热门文章

  1. Zynq中FPGA上电时序
  2. python模拟登陆 验证码el_python 模拟登陆163邮箱
  3. 对话魏杰:第三次造富时代来了 富翁进入洗牌期 未来十年机会最多
  4. 【软件推荐】身为高级unity工程师,电脑上的软件一览表,从工作顺序带你一览高级unity工程师所用的软件,如果高级是你的目标,这篇博客绝对不会让你失望
  5. 关于学习vue.js前端遇到的问题总结
  6. #9733;《唐琅探案》后记【2】
  7. 困时, 累时, 找些句子, 换一种方式思考
  8. Kubernetes应用生产(二)集群部署(安装篇)
  9. 高德地图的逆地理编码 | 将经纬度坐标转化为对应的地理位置
  10. 智能家居赛道上,小米vs华为谁更有优势?