-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplayscreen.h
More file actions
71 lines (58 loc) · 1.9 KB
/
Copy pathplayscreen.h
File metadata and controls
71 lines (58 loc) · 1.9 KB
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
#ifndef PLAYSCREEN_H
#define PLAYSCREEN_H
//AUTHORS: Matt Dumford, Anthony Phelps
#include "tile.h"
#include "mainwindow.h"
#include <QMainWindow>
#include <QPushButton>
#include <QGraphicsView>
#include <QGridLayout>
#include <QLabel>
#include <QString>
#include <QWidget>
#include <QTcpSocket>
// the playScreen is the screen for the single player game.
// it takes in the file path to the image the user wants to use
// and cuts it up into tiles and displays them on the screen with various
// menu buttons and statistics. It also handles tile clicks and tile swapping.
class PlayScreen : public QWidget
{
Q_OBJECT
public:
explicit PlayScreen(QString imgPath, MainWindow *mainWindow, QWidget *parent = 0);
void display(int screenWidth, int screenHeight, int gridSize = 5);
private:
int* findHiddenTile(int x, int y, int hiddenX, int hiddenY); //finds the position if the blank tile relative to another tile
void swapTiles(Tile *tile1, Tile *tile2); //switch the position of two tiles
void shuffle(); //shuffle the tiles
int calculatePercent(); //calculate the percent of the puzzle that is complete
void makeCon();
QString parseResponse(QString s);
int screenWidth, screenHeight;
QString imgPath; //file path to the user's chosen image
MainWindow *mainWindow;
QGridLayout *playGrid; //grid of tiles
Tile *hiddenTile;
int numMoves;
int seconds;
int percentComplete;
int grid;
QLabel *movesLabel;
QLabel *timerLabel;
QLabel *percentLabel;
QTimer *timer;
QTcpSocket *socket;
private slots:
void handleTileClick(Tile*);
void update(); //update the timer
void winButtonClicked();
void pauseButtonClicked();
void giveUpButtonClicked();
void playerWin();
//for uploading highscores
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
};
#endif // PLAYSCREEN_H