-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaze.cpp.autosave
More file actions
35 lines (34 loc) · 810 Bytes
/
Maze.cpp.autosave
File metadata and controls
35 lines (34 loc) · 810 Bytes
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
#include "Maze.h"
#include <QPainter>
#include <QTextStream>
#include <QFile>
#include <QMessageBox>
QVector<QString> Maze::field;
Maze::Maze(const Size &size)
{
this->size.height = size.height;
this->size.width = size.width;
}
Maze::Maze(int w, int h)
{
this->size.height = h;
this->size.width = w;
QFile file(":/res/resources/maze.txt");
if (!file.open (QIODevice::ReadOnly)) {
QMessageBox msg;
msg.setText ("Error! Can't read the maze!");
msg.show ();
}
QTextStream out(&file);
QString data = out.readLine ();
while (data != "") {
field.push_back (data);
data = out.readLine();
}
}
void Maze::draw (QPainter *painter) {
QPixmap img(":/res/resources/maze2.png");
painter->drawPixmap (0, 0, size.width, size.height, img);
}
void Maze::update() {
}