pro初始化

QT       += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \Ends.cpp \Enemyplane.cpp \Pause.cpp \Start.cpp \bomb_1.cpp \bomb_2.cpp \bomb_3.cpp \bomb_4.cpp \bullet.cpp \main.cpp \mainscene.cpp \map.cpp \menu.cpp \my_plane.cpp \rank.cpp \stop.cppHEADERS += \Ends.h \Enemyplane.h \Pause.h \Start.h \bomb_1.h \bomb_2.h \bomb_3.h \bomb_4.h \bullet.h \game.h \mainscene.h \map.h \menu.h \my_plane.h \rank.h \stop.hFORMS += \Start.ui \ends.ui \mainscene.ui \menu.ui \rank.ui# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetRESOURCES += \resure.qrcQT        += core gui multimediaQT       += core gui sql

头文件依次
爆炸效果1头文件

#ifndef BOMB_1_H
#define BOMB_1_H#include "game.h"
#include <QPixmap>
#include <QVector>class Bomb_1
{public:Bomb_1();void updateIfo();
public:QVector<QPixmap> m_pixAir;int m_x;int m_y;bool m_free;int m_Recoreder;int m_index;
};#endif // BOMB_1_H

爆炸效果2头文件

#ifndef BOMB_2_H
#define BOMB_2_H#include "game.h"
#include <QPixmap>
#include <QVector>class Bomb_2
{public:Bomb_2();void updateIfo();
public:QVector<QPixmap> m_pixAir;int m_x;int m_y;bool m_free;int m_Recoreder;int m_index;
};#endif // BOMB_2_H

爆炸效果3头文件

#ifndef BOMB_3_H
#define BOMB_3_H#include "game.h"
#include <QPixmap>
#include <QVector>class Bomb_3
{public:Bomb_3();void updateIfo();
public:QVector<QPixmap> m_pixAir;int m_x;int m_y;bool m_free;int m_Recoreder;int m_index;
};#endif // BOMB_3_H

飞机爆炸效果头文件

#ifndef BOMB_4_H
#define BOMB_4_H#include "game.h"
#include <QPixmap>
#include <QVector>class Bomb_4
{public:Bomb_4();void updateIfo();
public:QVector<QPixmap> m_pixAir;int m_x;int m_y;bool m_free;int m_Recoreder;int m_index;
};#endif // BOMB_4_H

子弹头文件`

#ifndef BULLET_H
#define BULLET_H
#include "game.h"#include <QPixmap>
#include <QRect>class bullet
{public:bullet();void updatePosition();
public:QPixmap m_bullet;int m_x;int m_y;int m_speed;bool m_free;QRect m_rect;// bool flag;
};#endif // BULLET_H

结束界面头文件

#ifndef ENDS_H
#define ENDS_H#include <QWidget>
#include "mainscene.h"namespace Ui {class Ends;
}class Ends : public QWidget
{Q_OBJECTpublic:explicit Ends(QWidget *parent = nullptr);~Ends();Ui::Ends *ui;int score;void get_score(int x);private slots:void on_pushButton_clicked();void on_groupBox_clicked();private://Mainscene a = new Mainscene();
};#endif // ENDS_H

敌机头文件

#ifndef ENEMYPLANE_H
#define ENEMYPLANE_H#include <QPixmap>class Enemyplane
{public:Enemyplane();void updatePoition();public:QPixmap m_enemy;QPixmap m_enemy2;QPixmap m_enemy3;QPixmap m_enemy4;QPixmap m_enemy5;int m_x;int m_y;QRect m_Rect;bool m_free;int m_speed;int type;
};#endif // ENEMYPLANE_H

定义变量头文件

#ifndef GAME_H
#define GAME_H/* 界面初始值*/
#define Game_width 480
#define Game_height 700
#define Game_title "大战✈"
#define Game_res_path "./plane.rcc"  //转换二进制文件/*刷新时间*/
#define Game_rate 10/*地图路径*/
#define Map_path ":/resource/background.png"
#define Map_scroll_speed 2    //地图滚动速度/*飞机参数*/
#define Plane_path ":/resource/me1.png"
#define Plane_speed 8/*子弹参数*/
#define Bullet_path ":/resource/bullet1.png"
#define Bullet_speed 2#define Bullet_num 30
#define Bullet_interval 20/*敌人参数*/
#define Enemy_path ":/resource/enemy2.png"
#define Enemy2_path ":/resource/enemy1.png"
#define Enemy3_path ":/resource/enemy3_n2.png"
#define Enemy4_path ":/resource/bullet_supply.png"
#define Enemy5_path ":/resource/bomb_supply.png"
#define Enemy_speed 4
#define Enemy_num 30
#define Enemy_interval 60   //敌人出现间隔/*爆炸参数*/
#define Bomb1_path ":/resource/enemy1_down%1.png"
#define Bomb1_num 20
#define Bomb1_max 4  //爆炸时有的图像数量
#define Bomb1_interval 20#define Bomb2_path ":/resource/enemy2_down%1.png"
#define Bomb2_num 20
#define Bomb2_max 4
#define Bomb2_interval 20#define Bomb3_path ":/resource/enemy3_down%1.png"
#define Bomb3_num 20
#define Bomb3_max 6
#define Bomb3_interval 20#define Bomb4_path ":/resource/enemy3_down%1.png"
#define Bomb4_num 20
#define Bomb4_max 4
#define Bomb4_interval 20/*暂停参数*/
#define Stop_path ":/resource/resume_nor.png"#define Sound_path ":/bgm1.wav"#define Pause1_path ":/resource/pause_nor.png"
#define Pause2_path ":/resource/pause_pressed.png"
#define Pause3_path ":/resource/resume_nor.png"
#define Pause4_path ":/resource/resume_pressed.png"
#define Pause_max 4
#define Pause_interval 20
#define Game_ends ":/resource/gameover.png"#endif // GAME_H/*按键操作:
P:单倍子弹
L:双倍子弹
O:炸弹
I:暂停
K:游戏直接结束
Space:左上角的游戏暂停
*/

主场景头文件

#ifndef MAINSCENE_H
#define MAINSCENE_H#include <QWidget>
#include <QTimer>
#include "map.h"
#include "my_plane.h"
#include "bullet.h"
#include "Ends.h"
#include "Enemyplane.h"
#include "bomb_1.h"
#include "bomb_2.h"
#include "bomb_3.h"
#include "bomb_4.h"
#include "stop.h"
#include "Pause.h"QT_BEGIN_NAMESPACE
namespace Ui { class Mainscene; }
QT_END_NAMESPACEclass Mainscene : public QWidget
{Q_OBJECTpublic:Mainscene(QWidget *parent = nullptr);~Mainscene();void init();void playGame();void updatePosition();//绘制到屏幕void paintEvent(QPaintEvent *);void keyPressEvent(QKeyEvent *);void keyReleaseEvent(QKeyEvent *);void mouseMoveEvent(QMouseEvent *);void Enemyshouw();void conflict1();void conflict2();int cnt = 0;void updateback();int get_score();void mouseReleaseEvent(QMouseEvent *);void get_info(QString str);Enemyplane m_enemy[Enemy_num];int enemy_recoder;int score;map m_map;// Ends *ss;My_plane hero_plane;QTimer m_Timer;Bomb_1 m_bomb1[Bomb1_num];Bomb_2 m_bomb2[Bomb2_num];Bomb_3 m_bomb3[Bomb3_num];Bomb_4 m_bomb4[Bomb4_num];bool W_free;bool S_free;bool A_free;bool D_free;Pause pause_state;int game_state;bool op;stop STOP;QString username;//bullet temp_bullet;
private:Ui::Mainscene *ui;
};
#endif // MAINSCENE_H

地图头文件

#ifndef MAP_H
#define MAP_H
#include <QPixmap>class map
{public:map();void mapPosition();public:QPixmap m_map1;QPixmap m_map2;int m_map1_posY;int m_map2_posY;int m_scroll_speed;
};#endif // MAP_H

菜单头文件

#ifndef MENU_H
#define MENU_H#include "mainscene.h"
#include <QDialog>namespace Ui {class menu;
}class menu : public QDialog
{Q_OBJECTpublic:explicit menu(QWidget *parent = nullptr);~menu();private slots://void on_buttonBox_clicked(QAbstractButton *button);void on_buttonBox_accepted();void on_pushButton_clicked();void on_pushButton_clicked(bool checked);void on_pushButton_2_clicked();void on_pushButton_3_clicked();void save();bool check();private:Ui::menu *ui;
};#endif // MENU_H

我方飞机头文件

#ifndef MY_PLANE_H
#define MY_PLANE_H#include "game.h"
#include "bullet.h"#include <QPixmap>
#include <QRect>class My_plane
{public:My_plane();void shoot_bullet();void shoot_bomb();void setPosition(int x, int y);public:int heights;int widths;QPixmap m_plane;int m_x;int m_y;int Num_bomb;int blood;int Num_bullet;QRect m_Rect;bool flag;bool flag2;bool check_bomb;bool m_free;int cnt = 0;// int score;QString username;bullet m_bullets[Bullet_num + 10];int m_recorder;
};#endif // MY_PLANE_H

暂停按钮头文件

#ifndef PAUSE_H
#define PAUSE_H#include <game.h>
#include <QPixmap>class Pause
{public:Pause();public:bool pause_pressed;QPixmap pause_background;QPixmap pause_pic1;QPixmap pause_pic2;QPixmap start_pic1;QPixmap start_pic2;QPixmap game_ends;int pause_pic_posX;int pause_pic_posY;bool game_paused;
};#endif // PAUSE_H

等级排行头文件

#ifndef RANK_H
#define RANK_H#include <QWidget>namespace Ui {class rank;
}class rank : public QWidget
{Q_OBJECTpublic:explicit rank(QWidget *parent = nullptr);~rank();private slots:void on_pushButton_clicked();private:Ui::rank *ui;
};#endif // RANK_H

开始界面头文件

#ifndef START_H
#define START_H#include <QWidget>namespace Ui {class Start;
}class Start : public QWidget
{Q_OBJECTpublic:explicit Start(QWidget *parent = nullptr);~Start();void get_str(QString username);QString str;private slots:void on_pushButton_clicked();private:Ui::Start *ui;
};#endif // START_H

另外一个暂停界面头文件

#ifndef STOP_H
#define STOP_H#include "game.h"
#include <QPixmap>class stop
{public:stop();
public:QPixmap Stop;int m_x;int m_y;bool m_free;
};#endif // STOP_H

CPP文件依次:
爆炸效果1函数

#include "bomb_1.h"
#include "game.h"#include <QDebug>Bomb_1::Bomb_1()
{m_pixAir.push_back(QPixmap(":/resource/enemy1_down1.png"));m_pixAir.push_back(QPixmap(":/resource/enemy1_down2.png"));m_pixAir.push_back(QPixmap(":/resource/enemy1_down3.png"));m_pixAir.push_back(QPixmap(":/resource/enemy1_down4.png"));m_x = 0;m_y = 0;m_free = true;/*当前是否需要爆炸,当前到了第几个图片,当前是否需要换图片*/m_index = 0;m_Recoreder = 0;
}void Bomb_1::updateIfo()
{/*判断是否应该有爆炸效果*/if (m_free)    return;m_Recoreder ++;/*如果间隔不够改变图片就结束*/if (m_Recoreder < Bomb1_interval){return;}/*实时修改信息*/m_Recoreder = 0;m_index ++;/*如果最后一张图片也更新完,修改信息*/if (m_index >= Bomb1_max){m_index = 0;m_free = true;}}

爆炸效果2函数:

#include "bomb_2.h"Bomb_2::Bomb_2()
{m_pixAir.push_back(QPixmap(":/resource/enemy2_down1.png"));m_pixAir.push_back(QPixmap(":/resource/enemy2_down2.png"));m_pixAir.push_back(QPixmap(":/resource/enemy2_down3.png"));m_pixAir.push_back(QPixmap(":/resource/enemy2_down4.png"));m_x = 0;m_y = 0;/*当前是否在爆炸,当前枚举到了第几张图片,当前是否需要换图片*/m_free = true;m_index = 0;m_Recoreder = 0;
}void Bomb_2::updateIfo()
{if (m_free)    return;m_Recoreder ++;if (m_Recoreder < Bomb2_interval){return;}m_Recoreder = 0;m_index ++;if (m_index >= Bomb2_max){m_index = 0;m_free = true;}
}

爆炸效果3函数

#include "bomb_3.h"Bomb_3::Bomb_3()
{m_pixAir.push_back(QPixmap(":/resource/enemy3_down1.png"));m_pixAir.push_back(QPixmap(":/resource/enemy3_down2.png"));m_pixAir.push_back(QPixmap(":/resource/enemy3_down3.png"));m_pixAir.push_back(QPixmap(":/resource/enemy3_down4.png"));m_pixAir.push_back(QPixmap(":/resource/enemy3_down4.png"));m_pixAir.push_back(QPixmap(":/resource/enemy3_down4.png"));m_x = 0;m_y = 0;/*当前是否在爆炸,当前枚举到了第几张图片,当前是否需要换图片*/m_free = true;m_index = 0;m_Recoreder = 0;
}void Bomb_3::updateIfo()
{if (m_free)    return;m_Recoreder ++;if (m_Recoreder < Bomb3_interval){return;}m_Recoreder = 0;m_index ++;if (m_index >= Bomb3_max){m_index = 0;m_free = true;}
}

自身爆炸效果函数

#include "bomb_4.h"Bomb_4::Bomb_4()
{m_pixAir.push_back(QPixmap(":/resource/me_destroy_1.png"));m_pixAir.push_back(QPixmap(":/resource/me_destroy_2.png"));m_pixAir.push_back(QPixmap(":/resource/me_destroy_3.png"));m_pixAir.push_back(QPixmap(":/resource/me_destroy_4.png"));m_x = 0;m_y = 0;/*当前是否在爆炸,当前枚举到了第几张图片,当前是否需要换图片*/m_free = true;m_index = 0;m_Recoreder = 0;
}void Bomb_4::updateIfo()
{if (m_free)    return;m_Recoreder ++;if (m_Recoreder < Bomb4_interval){return;}m_Recoreder = 0;m_index ++;if (m_index >= Bomb4_max){m_index = 0;m_free = true;}
}

子弹函数:

#include "bullet.h"
#include "game.h"#include <QRect>bullet::bullet()
{m_bullet.load(Bullet_path);m_x = (Game_width - m_bullet.width()) * 0.5;m_y = Game_height;m_free = true;m_speed = Bullet_speed;m_rect.setWidth(m_bullet.width());m_rect.setHeight(m_bullet.height());m_rect.moveTo(m_x, m_y);// flag = true;
}void bullet::updatePosition()
{if (m_free)   return;/*更新子弹的位置,如果射出去的话更新位置*/m_y -= m_speed;m_rect.moveTo(m_x, m_y);if (m_y <= m_rect.height()){m_free = true;}
}

结束界面函数:

#include "Ends.h"
#include "ui_ends.h"
#include "mainscene.h"
#include <QLabel>Ends::Ends(QWidget *parent) :QWidget(parent),ui(new Ui::Ends)
{ui->setupUi(this);//Mainscene a;/*设置UI界面的标签*/QString str = "Your score is " + QString::number(score);ui->label_2 -> setText(str);
}Ends::~Ends()
{delete ui;
}void Ends::on_pushButton_clicked()
{Mainscene *w = new Mainscene();w -> setWindowTitle(Game_title);w -> setWindowIcon(QIcon(":/resource/me1.png"));this -> close();w -> show();
}void Ends::on_groupBox_clicked()
{Mainscene *w = new Mainscene();w -> setWindowTitle(Game_title);w -> setWindowIcon(QIcon(":/resource/me1.png"));this -> close();w -> show();
}void Ends::get_score(int x)
{/*得到参数*/score = x;QString str = "Your score is " + QString::number(score);ui->label_2 -> setText(str);
}

敌机函数:

#include "Enemyplane.h"
#include "game.h"#include <QPixmap>
#include <QRect>Enemyplane::Enemyplane()
{m_enemy.load(Enemy_path);m_enemy2.load(Enemy2_path);m_enemy3.load(Enemy3_path);m_enemy4.load(Enemy4_path);m_enemy5.load(Enemy5_path);m_x = 0;m_y = 0;m_free = true;m_speed = Enemy_speed;m_Rect.setWidth(m_enemy.width());m_Rect.setHeight(m_enemy.height());m_Rect.moveTo(m_x, m_y);type = 10;
}void Enemyplane::updatePoition()
{if (m_free)    return;/*跟新敌机的位置,射出去的话改变状态*/m_y += Enemy_speed;m_Rect.moveTo(m_x, m_y);if (m_y >= Game_height + m_Rect.height()){m_y = 0;m_free = true;}
}

主场景函数:

#include "mainscene.h"
#include "ui_mainscene.h"
#include "game.h"
#include "Ends.h"
#include "my_plane.h"
#include "my_plane.h"
#include <QIcon>
#include <QPainter>
#include <QKeyEvent>
#include <QMouseEvent>
#include <ctime>
#include <QMessageBox>
#include <QLabel>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>
#include <QCoreApplication>
#include <QSound>Mainscene::Mainscene(QWidget *parent): QWidget(parent), ui(new Ui::Mainscene)
{score = 0;op = false;init();playGame();/*标记移动方向的状态*/W_free = false;S_free = false;A_free = false;D_free = false;ui->setupUi(this);;game_state = 1;
}Mainscene::~Mainscene()
{delete ui;
}void Mainscene::init()
{/*设置游戏页面长度和宽度*/setFixedSize(Game_width, Game_height);// setWindowIcon(QIcon(":/resource/again.png"));/*设置计时器间隔*/m_Timer.setInterval(Game_rate);enemy_recoder = 0;/*生成随机数种子*/srand((unsigned int)time(NULL));}void Mainscene::playGame(){QSound::play(Sound_path);m_Timer.start();/*计时器开始工作,每当感应到计时器工作的信号便发动槽函数*/connect(&m_Timer, &QTimer::timeout, [=](){/*如果是非暂停状态才更新各种位置*/if (game_state == 1 && !pause_state.game_paused){Enemyshouw();updatePosition();updateback();conflict1();if (op == false)   conflict2();}/*画出页面中的图形*/update();});if (op){}}void Mainscene::updatePosition()
{/*更新地图的位置*/m_map.mapPosition();// temp_bullet.m_free = false;//temp_bullet.updatePosition();/*飞机射击子弹*/hero_plane.shoot_bullet();/*根据状态移动飞机位置*/if (W_free){hero_plane.setPosition(hero_plane.m_x, hero_plane.m_y - Plane_speed);}if (S_free){hero_plane.setPosition(hero_plane.m_x, hero_plane.m_y + Plane_speed);}if (A_free){hero_plane.setPosition(hero_plane.m_x - Plane_speed, hero_plane.m_y);}if (D_free){hero_plane.setPosition(hero_plane.m_x + Plane_speed, hero_plane.m_y);}/*如果子弹状态为被射出,更改子弹状态*/for (int i = 0; i < Bullet_num; i ++){if (hero_plane.m_bullets[i].m_free == false){hero_plane.m_bullets[i].updatePosition();}}/*如果敌军状态为发动,更改敌军位置*/for (int i = 0; i < Enemy_num; i ++){if (m_enemy[i].m_free == false){m_enemy[i].updatePoition();}}/*如果某个爆炸发生了,实时改变爆炸效果的图片*/for (int i = 0; i < Bomb1_num; i ++){if (m_bomb1[i].m_free == false){m_bomb1[i].updateIfo();}if (m_bomb2[i].m_free == false){m_bomb2[i].updateIfo();}if (m_bomb3[i].m_free == false){m_bomb3[i].updateIfo();}if (m_bomb4[i].m_free == false){m_bomb4[i].updateIfo();}}
}void Mainscene::paintEvent(QPaintEvent *)
{QPainter painter(this);if (pause_state.game_paused){}/*如果当前暂停,只画暂停按钮*/if (STOP.m_free == false){painter.drawPixmap(STOP.m_x,STOP.m_y, STOP.Stop);// painter.drawPixmap(Game_height * 0.8, Game_width * 0.3, Pause.game_ends);return;}/*画出两张地图的位置*/painter.drawPixmap(0, m_map.m_map1_posY, m_map.m_map1);painter.drawPixmap(0, m_map.m_map2_posY, m_map.m_map2);/*画出飞机*/if (hero_plane.m_free)  painter.drawPixmap(hero_plane.m_x, hero_plane.m_y, hero_plane.m_plane);else{/*如果飞机被炸毁,计时器间隔80次再重新画出飞机*/hero_plane.cnt ++;if (hero_plane.cnt >= 80){hero_plane.cnt = 0;hero_plane.setPosition((Game_width - hero_plane.m_Rect.width()) * 0.5, Game_height-hero_plane.m_Rect.height());// hero_plane.blood --;painter.drawPixmap(hero_plane.m_x, hero_plane.m_y, hero_plane.m_plane);hero_plane.m_free = true;}}// painter.drawPixmap(0, m_map.m_map1_posY, m_map.m_map1);//painter.drawPixmap(0, m_map.m_map2_posY, m_map.m_map2);/*画出当前飞行的子弹*/for (int i = 0; i < Bullet_num - 1; i ++){if (hero_plane.m_bullets[i].m_free == false){painter.drawPixmap(hero_plane.m_bullets[i].m_x, hero_plane.m_bullets[i].m_y, hero_plane.m_bullets[i].m_bullet);}}/*画出敌军,根据敌军的随机函数生成的随机数判断生成哪架飞机并且修改敌机的方框*/for (int i = 0; i < Enemy_num; i ++){if (m_enemy[i].m_free == false){if (m_enemy[i].type == 0 || m_enemy[i].type == 1 || m_enemy[i].type == 2) painter.drawPixmap(m_enemy[i].m_x, m_enemy[i].m_y, m_enemy[i].m_enemy);else if (m_enemy[i].type == 3 || m_enemy[i].type == 4){m_enemy[i].m_Rect.setWidth(m_enemy[i].m_enemy2.width());painter.drawPixmap(m_enemy[i].m_x, m_enemy[i].m_y, m_enemy[i].m_enemy2);}else if (m_enemy[i].type == 5){m_enemy[i].m_Rect.setWidth(m_enemy[i].m_enemy3.width());painter.drawPixmap(m_enemy[i].m_x, m_enemy[i].m_y, m_enemy[i].m_enemy3);}else if (m_enemy[i].type == 6){m_enemy[i].m_Rect.setWidth(m_enemy[i].m_enemy4.width());painter.drawPixmap(m_enemy[i].m_x, m_enemy[i].m_y, m_enemy[i].m_enemy4);}else if (m_enemy[i].type == 7){m_enemy[i].m_Rect.setWidth(m_enemy[i].m_enemy5.width());painter.drawPixmap(m_enemy[i].m_x, m_enemy[i].m_y, m_enemy[i].m_enemy5);}}}/*画出爆炸效果所在的图*/for (int i = 0; i < Bomb1_num; i ++){if (m_bomb1[i].m_free == false){painter.drawPixmap(m_bomb1[i].m_x, m_bomb1[i].m_y, m_bomb1[i].m_pixAir[m_bomb1[i].m_index]);}if (m_bomb2[i].m_free == false){painter.drawPixmap(m_bomb2[i].m_x, m_bomb2[i].m_y, m_bomb2[i].m_pixAir[m_bomb2[i].m_index]);}if (m_bomb3[i].m_free == false){painter.drawPixmap(m_bomb3[i].m_x, m_bomb3[i].m_y, m_bomb3[i].m_pixAir[m_bomb3[i].m_index]);}if (m_bomb4[i].m_free == false){painter.drawPixmap(m_bomb4[i].m_x, m_bomb4[i].m_y, m_bomb4[i].m_pixAir[m_bomb4[i].m_index]);}}//暂停功能绘制if(pause_state.game_paused){/*暂停首先画出大背景*/painter.drawPixmap(0,0,pause_state.pause_background);/*画出游戏结束界面*/painter.drawPixmap(Game_width * 0.17, Game_height * 0.8, pause_state.game_ends);/*根据是否按压判断是哪张图*/if(pause_state.pause_pressed)painter.drawPixmap(pause_state.pause_pic_posX,pause_state.pause_pic_posY,pause_state.start_pic2);elsepainter.drawPixmap(pause_state.pause_pic_posX,pause_state.pause_pic_posY,pause_state.start_pic1);}else{/*根据是否按压判断是哪张图*/if(pause_state.pause_pressed)painter.drawPixmap(pause_state.pause_pic_posX,pause_state.pause_pic_posY,pause_state.pause_pic2);elsepainter.drawPixmap(pause_state.pause_pic_posX,pause_state.pause_pic_posY,pause_state.pause_pic1);}// painter.drawPixmap(temp_bullet.m_x, temp_bullet.m_y, temp_bullet.m_bullet);
}void Mainscene::keyPressEvent(QKeyEvent *k)
{/*方向键只更新状态*/switch(k -> key()){case Qt::Key_W :{// hero_plane.setPosition(hero_plane.m_x, hero_plane.m_y - Plane_speed);W_free = true;};break;case Qt::Key_S:{//hero_plane.setPosition(hero_plane.m_x, hero_plane.m_y + Plane_speed);S_free = true;};  break;case Qt::Key_A :{//hero_plane.setPosition(hero_plane.m_x - Plane_speed, hero_plane.m_y);A_free = true;};break;case Qt::Key_D :{//hero_plane.setPosition(hero_plane.m_x + Plane_speed, hero_plane.m_y);D_free = true;};break;case Qt::Key_P :{/*单倍子弹,标记子弹单倍子弹*/if (hero_plane.Num_bullet >= 0){hero_plane.flag = false;//hero_plane.Num_bullet --;}};break;case Qt::Key_L :{/*双倍子弹,标记双倍子弹*/if (hero_plane.Num_bullet >= 2){hero_plane.flag2 = false;hero_plane.Num_bullet -= 2;}};break;case Qt::Key_Q :{hero_plane.Num_bomb--;};break;case Qt::Key_O :{/*如果炸弹还有剩余*/if (hero_plane.Num_bomb > 0){hero_plane.check_bomb = false;hero_plane.Num_bomb --;for (int i = 0; i < Enemy_num; i ++){/*让所有子弹的状态改变*/m_enemy[i].m_free = true;if (m_enemy[i].type == 3 || m_enemy[i].type == 4 ){score += 1;/*出中等飞机的爆炸效果*/for (int k = 0; k < Bomb1_num; k ++){if (m_bomb1[k].m_free){m_bomb1[k].m_free = false;m_bomb1[k].m_x = m_enemy[i].m_x;m_bomb1[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 0 || m_enemy[i].type == 1 || m_enemy[i].type == 2){score += 2;for (int k = 0; k < Bomb2_num; k ++){if (m_bomb2[k].m_free){m_bomb2[k].m_free = false;m_bomb2[k].m_x = m_enemy[i].m_x;m_bomb2[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 5){score += 3;for (int k = 0; k < Bomb2_num; k ++){if (m_bomb3[k].m_free){m_bomb3[k].m_free = false;m_bomb3[k].m_x = m_enemy[i].m_x;m_bomb3[k].m_y = m_enemy[i].m_y;break;}}}}}else{}};break;case Qt::Key_I :{/*判断是否暂停并且改变位置*/if (m_Timer.isActive()){m_Timer.stop();STOP.m_free = false;update();}else{m_Timer.start();STOP.m_free = true;}};break;case Qt::Key_K :{/*关闭窗口*/this->close();}break;/*只按下空格时只修改压下去的状态*/case Qt::Key_Space:if(game_state == 1)pause_state.pause_pressed = true;break;/*其余任意按键*/default:if (op){/*展示结束画面*/this -> close();//QString str = "Your score is " + QString::number(get_score());//x -> ui -> label_2 -> setText(str);Ends *x = new Ends();//x -> score = score;x -> show();/*传递参数*/x->get_score(score);/*更新当前用户的分数信息*/QString update_sql = QString("update forms set score = '%1' where username = '%2'").arg(score).arg(username);QSqlQuery sql_query;// sql_query.exec(update_sql);if (sql_query.exec(update_sql)){// QMessageBox :: information(this, username, QString::number(score));}}}
}void Mainscene::keyReleaseEvent(QKeyEvent *event){/*按键松开修改状态*/switch(event->key()){case Qt::Key_W:{W_free = false;}break;case Qt::Key_S:{S_free = false;}break;case Qt::Key_A:{A_free = false;}break;case Qt::Key_D:{D_free = false;}break;/*松开空格时改变按压状态,并且修改游戏状态*/case Qt::Key_Space:if(game_state == 1){pause_state.pause_pressed = false;pause_state.game_paused = !pause_state.game_paused;}break;//松开}}void Mainscene::mouseMoveEvent(QMouseEvent *event)
{/*修改飞机位置*/hero_plane.setPosition(event -> x() - hero_plane.widths * 0.5, event -> y() - hero_plane.heights * 0.5);int x = event->x();int y = event->y();/*暂停位置状态修改*/if(x >= 0 && y >= 0 && x <=pause_state.pause_pic1.width() && y <= pause_state.pause_pic1.height()){if(game_state == 1){pause_state.pause_pressed = true;}}/*结束游戏状态修改*/if (x >= Game_width * 0.17 && y >= Game_height * 0.8 && x <= (Game_width * 0.17 + pause_state.game_ends.width()) && y <= (Game_height * 0.8 + pause_state.game_ends.height()))if (pause_state.game_paused)    this -> close();
}void Mainscene::mouseReleaseEvent(QMouseEvent *event){int x = event->x();int y = event->y();/*鼠标松开的状态修改*/if(x >= 0 && y >= 0 && x <= pause_state.pause_pic1.width() && y <= pause_state.pause_pic1.height()){if(game_state == 1){pause_state.pause_pressed = false;pause_state.game_paused = !pause_state.game_paused;}}/*游戏结束*/if (x >= Game_width * 0.17 && y >= Game_height * 0.8 && x <= (Game_width * 0.17 + pause_state.game_ends.width()) && y <= (Game_height * 0.8 + pause_state.game_ends.height()))if (pause_state.game_paused)    this -> close();
}void Mainscene::get_info(QString str)
{/*从开始界面得到用户的昵称*/username = str;
}void Mainscene::Enemyshouw()
{enemy_recoder ++;/*根据间隔确定敌机是否出现*/if (enemy_recoder <= Enemy_interval){return;}enemy_recoder = 0;/*找到任意一个当前空闲的敌机*/for (int i = 0; i < Enemy_num; i ++){if (m_enemy[i].m_free){m_enemy[i].m_free = false;/*横坐标与敌机的类型都是随机放置*/m_enemy[i].m_x = rand() % (Game_width - m_enemy[i].m_Rect.width());m_enemy[i].m_y = -m_enemy[i].m_Rect.height();m_enemy[i].type = rand() % 8;break;}}
}void Mainscene::conflict1()
{for (int i = 0; i < Enemy_num; i ++){if (m_enemy[i].m_free)      continue;for (int j = 0; j < Bullet_num; j ++){if (hero_plane.m_bullets[j].m_free){continue;}/*如果某个敌机与某个子弹发生碰撞*/if (m_enemy[i].m_Rect.intersects(hero_plane.m_bullets[j].m_rect)){m_enemy[i].m_free = true;if (m_enemy[i].type == 3 || m_enemy[i].type == 4 ){score += 1;/*展示对应的动画*/for (int k = 0; k < Bomb1_num; k ++){if (m_bomb1[k].m_free){m_bomb1[k].m_free = false;m_bomb1[k].m_x = m_enemy[i].m_x;m_bomb1[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 0 || m_enemy[i].type == 1 || m_enemy[i].type == 2){score += 2;for (int k = 0; k < Bomb2_num; k ++){if (m_bomb2[k].m_free){m_bomb2[k].m_free = false;m_bomb2[k].m_x = m_enemy[i].m_x;m_bomb2[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 5){score += 3;for (int k = 0; k < Bomb3_num; k ++){if (m_bomb3[k].m_free){m_bomb3[k].m_free = false;m_bomb3[k].m_x = m_enemy[i].m_x;m_bomb3[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 6){hero_plane.Num_bullet += 20;}else if (m_enemy[i].type == 7){hero_plane.Num_bomb += 1;}hero_plane.m_bullets[j].m_free = true;}}}
}void Mainscene::conflict2()
{for (int i = 0; i < Enemy_num; i ++){if (m_enemy[i].m_free)      continue;/*如果某个敌机与飞机碰撞*/if (m_enemy[i].m_Rect.intersects(hero_plane.m_Rect)){m_enemy[i].m_free = true;
/*if (m_enemy[i].type == 6){hero_plane.Num_bullet += 20;break;}else if (m_enemy[i].type == 7){hero_plane.Num_bomb += 1;break;}
*//*展示飞机的动画*/for (int k = 0; k < Bomb4_num; k ++){if (m_bomb4[k].m_free){m_bomb4[k].m_free = false;m_bomb4[k].m_x = hero_plane.m_x;m_bomb4[k].m_y = hero_plane.m_y;hero_plane.m_free = false;break;}}/*飞机回到出生点*/hero_plane.setPosition((Game_width - hero_plane.m_Rect.width()) * 0.5, Game_height-hero_plane.m_Rect.height());hero_plane.blood --;hero_plane.Num_bullet = 0;/*for (int i = 0; i < Enemy_num; i ++){m_enemy[i].m_free = true;if (m_enemy[i].type == 3 || m_enemy[i].type == 4 ){// score += 1;for (int k = 0; k < Bomb1_num; k ++){if (m_bomb1[k].m_free){m_bomb1[k].m_free = false;m_bomb1[k].m_x = m_enemy[i].m_x;m_bomb1[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 0 || m_enemy[i].type == 1 || m_enemy[i].type == 2){//score += 2;for (int k = 0; k < Bomb2_num; k ++){if (m_bomb2[k].m_free){m_bomb2[k].m_free = false;m_bomb2[k].m_x = m_enemy[i].m_x;m_bomb2[k].m_y = m_enemy[i].m_y;break;}}}else if (m_enemy[i].type == 5){// score += 3;for (int k = 0; k < Bomb2_num; k ++){if (m_bomb3[k].m_free){m_bomb3[k].m_free = false;m_bomb3[k].m_x = m_enemy[i].m_x;m_bomb3[k].m_y = m_enemy[i].m_y;break;}}}}*/if (hero_plane.blood != 0)   break;if (hero_plane.blood == 0 && op == false){/*血量为0计时器关闭*/m_Timer.stop();Enemyshouw();updatePosition();updateback();update();// hero_plane.blood --;op = true;//hero_plane.blood = 3;// QMessageBox :: information(this,"", "Game over!"op = true;}}}
}void Mainscene::updateback()
{/*随时根据计时器更新右上角的信息*/QString str = "live:" + QString::number(hero_plane.blood);ui->label -> setText(str);ui -> label -> setStyleSheet("color:blue;");str = "bullet:" + QString::number(hero_plane.Num_bullet);ui->label_2 -> setText(str);ui->label_2 -> setStyleSheet("color:blue;");str = "bomb:" + QString::number(hero_plane.Num_bomb);ui->label_3 -> setText(str);ui->label_3 -> setStyleSheet("color:blue;");str = "score:" + QString::number(score);ui->label_4 -> setText(str);ui->label_4 -> setStyleSheet("color:blue;");
}int Mainscene::get_score()
{/*传递给结束界面窗口函数*/return score;
}

主函数:

#include "mainscene.h"
#include "game.h"
#include "menu.h"#include <QApplication>
#include <QResource>
#include <QIcon>
#include <QtSql/QSqlDatabase>
#include<QDebug>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>
#include <QCoreApplication>
#include"rank.h"int main(int argc, char *argv[])
{QApplication a(argc, argv);QResource::registerResource("./plane.rcc");  //导入资源文件//创建数据库-----QSqlDatabase  db=QSqlDatabase::addDatabase("QSQLITE");//设置数据库名db.setDatabaseName("pwd.db");//打开数据库db.open();//创建数据库表QString cmd="create table if not exists forms(username varchar(64),password varchar(64), score int)";//执行sql语句QSqlQuery query;query.exec(cmd);menu ww;ww.show();  //显示主菜单界面Mainscene w;w.setWindowTitle(Game_title);w.setWindowIcon(QIcon(":/resource/me1.png"));//w.show();return a.exec();
}

地图函数:

#include "map.h"
#include "game.h"map::map()
{m_map1.load(Map_path);m_map2.load(Map_path);m_map1_posY = -Game_height;m_map2_posY = 0;m_scroll_speed = Map_scroll_speed;
}void map::mapPosition()
{/*更新地图的位置,滑动地图*/m_map1_posY += m_scroll_speed;if (m_map1_posY >= 0){m_map1_posY = -Game_height;}m_map2_posY += m_scroll_speed;if (m_map2_posY >= Game_height){m_map2_posY = 0;}
}

主菜单函数:

#include "menu.h"
#include "ui_menu.h"
#include "mainscene.h"
#include "game.h"
#include "rank.h"
#include "Start.h"#include <QLineEdit>
#include <QMessageBox>
#include <QFileDialog>
#include <QFile>
#include<QMessageBox>
#include<QKeyEvent>
#include<QtSql/QSqlQuery>
#include<QtSql/QSqlTableModel>
#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>
#include <QCoreApplication>menu::menu(QWidget *parent) :QDialog(parent),ui(new Ui::menu)
{ui->setupUi(this);/*设置登陆界面的的密码格式以及字体格式*/ui->lineEdit_2->setEchoMode(QLineEdit::Password);ui->lineEdit->setFont(QFont("Timers" , 16 ,  QFont::Bold));ui->lineEdit_2->setFont(QFont("Timers" , 16 ,  QFont::Bold));
}menu::~menu()
{delete ui;
}bool menu:: check()
{/*检查用户密码是否正确,首先提取出用户密码*/QString username= this->ui->lineEdit->text();QString password=this->ui->lineEdit_2->text();//查询数据库验证QSqlTableModel *model =new QSqlTableModel;model->setTable("forms");model->setFilter(QString("username='%1' and password='%2'").arg(username).arg(password));model->select();//检测是否有数据int row=model->rowCount();//判断用户密码在数据库的第几行if(row>0){return true;}return false;/*QString str;QString temp;QString filename = QFileDialog::getOpenFileName(this, "打开文件", ".", "Txt(*.txt);;c files(*.c);; cpp files(*.cpp)");if(filename.isEmpty() == false){QFile file(filename);bool isok = file.open(QIODevice::ReadOnly);//以只读的方式打开文件if(isok == true){QByteArray array;while(file.atEnd() == false){str = this->ui->lineEdit->text() + " " + this->ui->lineEdit_2->text();temp = file.readLine();//将文件中的读取的内容保存在字节数组中。}}file.close();//文件读取完毕后关闭文件。}if (str == temp)   return true;else   return false;*/
}void menu::on_pushButton_clicked()
{if (check()){/*弹出开始页面窗口*/Start *w = new Start();//w -> setWindowTitle(Game_title);// w -> setWindowIcon(QIcon(":/resource/me1.png"));this -> close();w -> show();w -> get_str(this->ui->lineEdit->text());}else{/*密码不对的话弹出窗口*/QMessageBox :: information(this, this->ui->lineEdit->text(), "PassWord Wrong");}
}void menu::save()
{/*读出输入的信息*/QString username=ui->lineEdit->text();QString password=ui->lineEdit_2->text();/*存储到数据库中*/QString cmd=QString("insert into forms values('%1','%2','%3')").arg(username) .arg(password).arg(0);QSqlQuery query;/*执行插入语句*/if(query.exec(cmd)){//QMessageBox::warning(this, tr("注册提示"), tr("注册成功"), QMessageBox::Yes);}else{//  QMessageBox::warning(this, tr("注册提示"), tr("注册失败"), QMessageBox::Yes);}/*QString filename = QFileDialog::getSaveFileName(this, "save.txt", ".", "Txt(*.txt);;c files(*.c);;c++ files(*.cpp)");if(filename.isEmpty() == false){QFile file(filename);bool isok = file.open(QIODevice::WriteOnly);if(isok == true){QString str = this->ui->lineEdit->text() + " " + this->ui->lineEdit_2->text();file.write(str.toUtf8());}file.close();}*/
/*QFile file("C:/Users/wwb0719/Desktop/save.txt");QString str = this->ui->lineEdit->text() + " " + this->ui->lineEdit_2->text();fputs(str, file);// file.write()*/
}void menu::on_pushButton_2_clicked()
{/*弹出提示注册成功的窗口*/QMessageBox :: information(this, this->ui->lineEdit->text(), "Register successful");save();
}void menu::on_pushButton_3_clicked()
{// QSqlTableModel *model =new QSqlTableModel;// model->setTable("userinforms");/*关闭原来窗口,弹出分数排行*/rank *w = new rank();this -> close();w -> show();}

我方飞机函数:

#include "my_plane.h"
#include "game.h"
#include "Enemyplane.h"
#include "mainscene.h"
#include "ui_mainscene.h"
#include "game.h"
#include "my_plane.h"
#include "my_plane.h"
#include <QIcon>
#include <QPainter>
#include <QKeyEvent>
#include <QMouseEvent>
#include <ctime>
#include <QLabel>My_plane::My_plane()
{m_plane.load(Plane_path); //飞机初始化m_x = (Game_width - m_plane.width()) * 0.5;widths = m_plane.width();heights = m_plane.height();m_y = Game_height-m_plane.height();//Num_bullet = 80;Num_bomb = 1;blood = 3;Num_bullet = 20;m_free = true;  /*标记飞机此时的状态*/m_Rect.setWidth(m_plane.width());m_Rect.setHeight(m_plane.height());m_Rect.moveTo(m_x, m_y);flag = true;flag2 = true;check_bomb = true;cnt ++;
}void My_plane::shoot_bullet()
{m_recorder ++;if (flag && flag2){return;}/*设计单倍子弹*/if (flag == false){for (int i = 0; i < Bullet_num; i ++){if (m_bullets[i].m_free == true){/*设置子弹初始位置,标记子弹状态*/m_bullets[i].m_free = false;m_bullets[i].m_x = m_x + m_Rect.width() * 0.5 + 5;m_bullets[i].m_y = m_y - 30;break;}}}/*设计双倍子弹*/if (flag2 == false){/*连续设置两个子弹的初始位置,标记子弹状态*/for (int i = 0; i < Bullet_num; i ++){if (m_bullets[i].m_free == true){m_bullets[i].m_free = false;m_bullets[i].m_x = m_x ;m_bullets[i].m_y = m_y - 30;break;}}for (int i = 0; i < Bullet_num; i ++){if (m_bullets[i].m_free == true){m_bullets[i].m_free = false;m_bullets[i].m_x = m_x + m_Rect.width() * 0.5 + 30;m_bullets[i].m_y = m_y - 30;break;}}}/*保证只射击一次*/flag2 = true;flag = true;}void My_plane::shoot_bomb()
{if (check_bomb){return;}check_bomb = true;for (int i = 0; i < Enemy_num; i ++){//     m_enemy[i].m_free = true;}return;
}void My_plane::setPosition(int x, int y)
{/*更改飞机位置并且移动边框*/if (x <= 0)             x = 0;if (x >= Game_width - m_plane.width())    x = Game_width - m_plane.width();if (y <= 0)             y = 0;if (y >= Game_height - m_plane.height())    y = Game_height - m_plane.height();m_x = x;m_y = y;m_Rect.moveTo(m_x, m_y);
}

暂停函数:

#include "Pause.h"Pause::Pause()
{/*是否按下去,游戏是否进行*/pause_pressed = false;game_paused = false;pause_background.load(Map_path);pause_pic1.load(Pause1_path);pause_pic2.load(Pause2_path);start_pic1.load(Pause3_path);start_pic2.load(Pause4_path);game_ends.load(Game_ends);pause_pic_posX = 0;pause_pic_posY = 0;
}

等级函数:

#include "rank.h"
#include "ui_rank.h"
#include "menu.h"
#include<QtSql/QSqlQuery>
#include<QtSql/QSqlTableModel>
#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>
#include <QMessageBox>
#include <QCoreApplication>rank::rank(QWidget *parent) :QWidget(parent),ui(new Ui::rank)
{ui->setupUi(this);//QString update_sql = QString("update forms set score = %1 where username = %2").arg(10).arg("123");//QSqlQuery sql_query;// sql_query.exec(update_sql);//if (sql_query.exec(update_sql))//{//QMessageBox :: information(this, username, QString::number(score));//}/*查询数据库的语句*/QString cmd=QString("select username, score from forms order by score desc");QSqlQuery query;/*执行查询操作*/if(query.exec(cmd)){// QMessageBox::warning(this, tr("注册提示"), tr("注册成功"), QMessageBox::Yes);}else{//QMessageBox::warning(this, tr("注册提示"), tr("注册失败"), QMessageBox::Yes);}while(query.next()){/*提取出姓名和分数*/QString name = query.value(0).toString();QString score = query.value(1).toString();// QMessageBox::warning(this, tr("注册提示"), tr("注册成功"), QMessageBox::Yes);//QMessageBox :: information(this, name, score);QString temp = name + "            " + score;/*加入大的编辑框*/ui -> textEdit->append(temp);}}rank::~rank()
{delete ui;
}void rank::on_pushButton_clicked()
{/*槽,返回菜单界面*/menu *w = new menu();this -> close();w -> show();
}

开始函数:

#include "Start.h"
#include "ui_Start.h"
#include "mainscene.h"Start::Start(QWidget *parent) :QWidget(parent),ui(new Ui::Start)
{ui->setupUi(this);
}Start::~Start()
{delete ui;
}void Start::get_str(QString username)
{str = username;
}void Start::on_pushButton_clicked()
{/*弹出游戏页面*/Mainscene *w = new Mainscene();w -> setWindowTitle(Game_title);w -> setWindowIcon(QIcon(":/resource/me1.png"));this -> close();w -> show();w->get_info(str);
}

另外一个暂停函数:

#include "stop.h"
#include "game.h"
#include <QPixmap>stop::stop()
{Stop.load(Stop_path);m_x = Game_width * 0.5;m_y = Game_height * 0.5;m_free = true;
}

结束游戏UI

主场景UI

登陆界面UI

排行榜UI

开始游戏UI

QT(飞机大战)课设相关推荐

  1. QT 杀毒软件(课设)

    QT 杀毒软件(课设) 开发语言:C++ 开发工具:Qt Creator (QT5) 杀毒软件功能要求 病毒特征库管理(可增删查改病毒特征库) U盘扫描(U盘插入进行扫描) 安全运行程序(检索病毒库, ...

  2. QT飞机大战三(子弹类)

    前文链接如下所示 QT飞机大战一(游戏场景配置) QT飞机大战二(飞机类) 如图所示,子弹会不断从飞机的位置射出来 那么子弹这个类肯定有自己的位置坐标 肯定有自己的资源图片 既然子弹需要"射 ...

  3. QT五子棋游戏课设及源码(连接mysql数据库含打开并运行程序的教程)

    gdut大一下学期c++课设(得分:95) 实验报告及源码压缩包百度云下载: 链接:https://pan.baidu.com/s/1zO5ofMz09fiWihxCcZcFbg 提取码:ddav 首 ...

  4. java坦克大战的总结_关于坦克大战课设的个人总结

    一·团队课程设计博客链接 二·个人负责模块 基地类,墙块类,爆炸效果类,地图类 三·代码提交记录截图 四·任务详细说明 基地类:基地是游戏的关键元素,玩家要保证在基地不被摧毁之前消灭敌方坦克,基地的坐 ...

  5. QT飞机大战五(碰撞爆炸特效类)

    如图所示,在子弹碰到敌机时,同时产生爆炸特效,显得不那么突兀 那么怎么做到的呢?? 其实也很简单,爆炸特效由一些图片组成,每当我们检测到子弹和敌机相交时 就在这个位置播放一个爆炸特效,那么爆炸也可以封 ...

  6. java坦克大战课设报告_java课程设计之坦克大战

    本文实例为大家分享了java坦克大战的具体代码,供大家参考,具体内容如下 环境要求: 操作系统:Windows 10 JAVA虚拟机:JDK1.8以上 开发环境:Eclipse(4.5以上) 功能提示 ...

  7. Qt飞机大战小游戏(c++从零开始实现)

    本弱鸡一直想写一个"可以玩的"图形界面游戏,苦于一直没动力,正好前几天面试官要求一个星期写一个游戏demo出来,所以就开肝了... 游戏运行包:https://download.c ...

  8. QT飞机大战六(敌机血条的添加以及特殊子弹道具)

    可能有点丑但其实是没有好的资源图片 比如这个血条太生硬了,这个子弹道具怎么真的就和子弹一样?? 不过没事,功能对了就行 首先考虑这个血条怎么搞. 那么首先我们的敌机需要有个属性sum_hp(总血量), ...

  9. 游戏角色坐标的保存间隔_使用C++编写飞机大战游戏【手把手教程】

    友情地提示本文较长,建议保存,慢慢学学.可以直接观看视频教程. C++干大事系列之游戏篇:Qt飞机大战​yun.itheima.com 1.项目简介 飞机大战是我们大家所熟知的一款小游戏,本教程就是教 ...

  10. Qt学习总结——飞机大战小游戏制作

    Qt学习总结--飞机大战小游戏制作 1. 需求分析 这篇文章写于2020年暑假,完成学校实训项目之后,对自己的项目实践做了一个总结,回顾整个项目的制作过程,同时也复习一下Qt的相关知识,总结项目制作过 ...

最新文章

  1. 漫谈 ClickHouse 在实时分析系统中的定位与作用
  2. Apache CXF实战之六 创建安全的Web Service
  3. 查询a表有但是b表没有的数据_牛逼!一个上亿数据的报表竟然能做到秒查~
  4. 程序员接私活的途径以及正确方式。
  5. 多帧点云数据拼接合并_多工作簿数据合并,还在手动复制粘贴就out了,用批处理一键搞定...
  6. 北斗导航 | 卫星导航系统时间转换:闰年(附C源代码)
  7. 离线转义 reactjs JSX
  8. aws sqs_JMS和AWS SQS的更多高级内容
  9. 手机是怎么确定位置信息的?
  10. mysql show
  11. RHEL5实现YUM本地源的配置
  12. Linux系统Zookeeper集群配置
  13. [大数据之Sqoop] —— 什么是Sqoop?
  14. (数字IC)低功耗设计入门(五)——RTL级低功耗设计(续)
  15. Linux 命令之 gzip -- 压缩和解压文件
  16. HP Socket Pack笔记
  17. SAP_ABAP 采购价格条件报表(改进版1)
  18. 解决“手机锂电池无输出电压,无法充电”
  19. JS的特性:异步 + 事件驱动
  20. Caffe-SCIR

热门文章

  1. ACCESS数据库开发-DLookup and DCount
  2. Linux课程特点与目标
  3. 程序员的奋斗史(三十八)——大学断代史(二)——我与数据库的故事
  4. HTTP协议, 浏览器访问服务器, HTTP响应, HTTP请求, 访问百度
  5. 少儿编程应该学哪些课程
  6. 腾讯QQ、淘宝旺旺、微软MSN、谷歌Gtalk 在线客服代码
  7. Esp8266 进阶之路35【项目篇】借助机智云平台用乐鑫esp8266芯片做一个商业化的七彩RGB灯泡可调整体方案项目,炫彩夺目高大尚。
  8. 2021年R1快开门式压力容器操作复审考试及R1快开门式压力容器操作复审模拟考试
  9. T100常用的Debug命令和XShell常用命令
  10. OBS推流到EasyDSS平台匿名直播时却在其他直播间生成了录像文件该如何解决?