-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgamewidget.h
151 lines (130 loc) · 3.45 KB
/
gamewidget.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
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
#ifndef GAMEWIDGET_H
#define GAMEWIDGET_H
#include <iostream>
#include <string.h>
#include <QWidget>
#include <QKeyEvent>
#include <QLabel>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
#include <QIcon>
#include <QTimer>
#include <hoverbutton.h>
#include <myprobar.h>
#include <QRandomGenerator>
#include "gem.h"
#include <QTime>
#include <QMainWindow>
#include<qsound.h>
#include<qsoundeffect.h>
#include<QTemporaryDir>
#include <QFont>
#include <QMessageBox>
#include"settingpage.h"
#include"database.h"
#include "client.h"
#define TO_BOMB 100
extern Client *client;
extern database *mysql;
class Point{
public:
int x;
int y;
Point(int x1,int y1){
x=x1;
y=y1;
}
};
namespace Ui {
class GameWidget;
}
class GameWidget : public QMainWindow
{
Q_OBJECT
public:
int DIFFICULITY=5;
bool challenge=0;
explicit GameWidget(QWidget *parent = nullptr);
void setAdaptedImg(QString path,QLabel *label);
void setupScene(int i);
QSoundEffect* sound;
protected:
virtual void keyPressEvent(QKeyEvent *ev)override;
private:
bool gameOver=false;
int FTime=0;
int mousePosX=-1,mousePosY=-1;
bool exitMagic=false;
int hintArrowTimes=6;
int score=0;
bool is_acting=false;
bool is_paused=false;
int eliminateTimes=0;
QSound *effect=nullptr ;
QLabel* scoreTextLbl=nullptr;
QLabel* pauseBKLbl = nullptr;
QMovie* pauseBKgif = nullptr;
QLabel* pauseTXLbl = nullptr;
int fallNum=0;
int fallCount=0;
unsigned int gemType[8][8];//type数组
Gem* gems[8][8];//gem对象数组
int fallHeight[8][8];//掉落高度数组
std::vector<Gem*> bombList; //存要消去的宝石
int updateBombList();
QWidget* boardWidget=nullptr;
HoverButton *reSetButton=nullptr;
HoverButton *menuButton=nullptr;
HoverButton *hintButton=nullptr;
HoverButton *pauseButton=nullptr;
HoverButton *freezeButton=nullptr;
MyProBar* progressBar=nullptr;
MyProBar* frozenBar=nullptr;
QTimer *progressTimer=nullptr;
QLabel* selectedLbl=nullptr;
QTimer* timeoutTimer=nullptr;
QLabel* outLabel=nullptr;
QTimer* redBorderTimer=nullptr;
QLabel* redBorder=nullptr;
int redBordershow=0;
double trans=0;
QPropertyAnimation* startfallAnimation(Gem *gem, int h);
int randomGem();
void startGame();
void fall();
void fill();
void magicFall();
void magicFill();
void makeStopSpin(int,int);
void makeSpin(int,int);
void swap(int, int, int gemX,int gemY);
void eliminateBoard();
Point tipsdetect();
void fallAnimation(Gem *gem, int h);
void fillfallAnimation(Gem *gem, int h);
void Sleep(int msec);
void act(Gem* gem);
int selectedX=-1,selectedY=-1;
void playSound(int type);
void forbidAll(bool forbid);
std::vector<Gem*> bombsToMakeMagic1;
std::vector<Gem*> bombsToMakeMagic2;
std::vector<Gem*> tList1;
std::vector<Gem*> tList2;
int getBombsToMakeMagic(int cX,int cY,std::vector<Gem*> bombsToMakeMagic,int time);
void generateMagic(int cX,int cY,int type,int time);
void finishAct();
int tHeight[8][8];
void magicCollect(int coType,int toX,int toY);
settingpage settingP;
void allFallOut();
void reSetBoard();
Ui::GameWidget *ui;
signals:
void showStartPage();
void eliminateFinished();
void myMouseMove(QMouseEvent*);
void finishCount();
};
#endif // GAMEWIDGET_H