-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
42 lines (34 loc) · 1.14 KB
/
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
38
39
40
41
42
#ifndef PAINTWIDGET_H
#define PAINTWIDGET_H
#include <QtWidgets>
#include "snake.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget * parent = 0);
~MainWindow();
protected slots:
void timeout(void); //自定义的槽函数,处理定时器时间,用于游戏更新
void showAbout(void); //自定义的槽函数,显示关于信息
void showHelp(void); //自定义的槽函数,显示帮助信息
void startGame(void); //自定义的槽函数,开始游戏
void pauseGame(void); //自定义的槽函数,暂停游戏
void speedUp(void); //自定义的槽函数,游戏加速
void speedDown(void); //自定义的槽函数,游戏减速
protected:
void keyPressEvent(QKeyEvent * event); //处理按键消息
void paintEvent(QPaintEvent * event); //处理重绘消息
private:
void dealMenu(void); //处理菜单的函数
void dealRank();
private:
Snake snake; //贪食蛇的类
bool IsDie; //游戏是否结束
bool run; //游戏是否运行的变量
QTimer * timer; //游戏定时器
int times; //定时器的频率
int MenuBarSize; //菜单栏所占的位置
QLabel * info;
};
#endif