-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobotgridmatrix.cpp
More file actions
43 lines (34 loc) · 1.62 KB
/
robotgridmatrix.cpp
File metadata and controls
43 lines (34 loc) · 1.62 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
#include "robotgridmatrix.h"
#define PATH QString(":/terrain/grounds.png")
#define WALL QString(":/terrain/regular.png")
RobotGridMatrix::RobotGridMatrix(QList<RobotGridItem *> items){
qDebug("RobotGridMatrix::RobotGridMatrix() => called...");
this->items = &items;
qDebug("RobotGridMatrix::RobotGridMatrix() => initialized without errors...");
}
void RobotGridMatrix::ImportMaze(int maze[8][10]){
qDebug("RobotGridMatrix::ImportMaze() => conversion initialized");
for (int i = 0; i<8; i++) {
for (int j = 0; j<10; j++) {
switch(maze[i][j]) {
case 0: this->items->append(new RobotGridItem(WALL,0,QPoint(j,i)));this->Maze[i][j] = maze[i][j]; break;
case 1: this->items->append(new RobotGridItem(PATH,0,QPoint(j,i)));this->Maze[i][j] = maze[i][j]; break;
case 2: this->items->append(new RobotGridItem(PATH,0,QPoint(j,i)));this->Maze[i][j] = maze[i][j]; break;
case 3: this->items->append(new RobotGridItem(PATH,0,QPoint(j,i)));this->Maze[i][j] = maze[i][j]; break;
}
}
}
qDebug("RobotGridMatrix::ImportMaze() => conversion success");
}
RobotGridMatrix::~RobotGridMatrix(){
}
void RobotGridMatrix::AttachToScene(QGraphicsScene *scene){
QListIterator<RobotGridItem*> i(*items);
while(i.hasNext()) scene->addItem(i.next());
}
void RobotGridMatrix::MapToScene(Map imp){
QList<map>::Iterator actual;
for(actual = imp.maze.begin(); actual != imp.maze.end(); ++actual){
this->items->append(new RobotGridItem(imp.popTrrain((*actual).coords),0,(*actual).coords));
}
}