/
GuessTheNumber_WithGraphics.h
122 lines (87 loc) · 2.37 KB
/
GuessTheNumber_WithGraphics.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
#ifndef GUESSTHENUMBER_WITHGRAPHICS_H
#define GUESSTHENUMBER_WITHGRAPHICS_H
#include <QMainWindow>
#include <QIntValidator>
#include <QString>
#include <QMessageBox>
#include <QTimer>
#include <QTime>
#include <QShortcut>
#include <QEvent>
#include <QFileInfo>
#include <QTextStream>
#include <QKeyEvent>
#include <QtWidgets>
#include "ui_GuessTheNumber_WithGraphics.h"
namespace Ui {
class GuessTheNumber_WithGraphics;
}
class GuessTheNumber_WithGraphics : public QMainWindow
{
Q_OBJECT
public:
explicit GuessTheNumber_WithGraphics(QVector<int> _settings_,QWidget *parent = nullptr);
int getlvl()
{
return lvl;
}
int lvl = 1;
private:
QVector<int> settings[5];
QTimer *timer = new QTimer(this);
int scatter = 100;
int input = 0;
int number = 0;
int remaining_moves = 10;
int moves = 10;
Ui::GuessTheNumber_WithGraphics *ui;
signals:
void win();
void game_over();
private slots:
void ok_clicked();
void clue_clicked();
int help_clicked();
void gameOver()
{
close();
}
void timer_()
{
timer->stop();
ui->ok->setEnabled(true);
ui->clue->setEnabled(true);
ui->help->setEnabled(true);
emit win();
}
void set()
{
srand(time(NULL));
moves = moves + moves;
remaining_moves += moves;
ui->moves->setText("remaining moves: " + QString::number(remaining_moves));
QFont font = ui->moves->font();
font.setPointSize(36);
ui->moves->setFont(font);
ui->moves->setStyleSheet("color: rgb(255, 255, 255)");
lvl++;
QFile file("Save.txt");
if(file.open(QIODevice::WriteOnly))
{
QFileInfo fileinfo (file);
QTextStream stream(&file);
// stream << QString::number(nullptr);
stream << QString::number(lvl);
file.close();
}
setWindowTitle("Guess The Number|LvL " + QString::number(lvl));
scatter += scatter;
ui->answer->setText("Guess the next number from 1 to " + QString::number(scatter));
QFont font_ = ui->answer->font();
font_.setPointSize(36);
ui->answer->setFont(font_);
ui->answer->setStyleSheet("color: rgb(255, 255, 255)");
number = 1 + rand() % scatter;
}
};
#endif // GUESSTHENUMBER_WITHGRAPHICS_H