-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabyrinth.cpp
More file actions
70 lines (51 loc) · 1.16 KB
/
Labyrinth.cpp
File metadata and controls
70 lines (51 loc) · 1.16 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
//
// Labyrinth.cpp
// VirtualMarbleGame
//
// Created by Maximilian Weber
//
#include <iostream>
#include <fstream>
#include "Labyrinth.h"
#include "Labyrinth.h"
#include "maze.c"
using namespace std;
void Labyrinth::createMaze()
{
GenerateMaze(m_map, Labyrinth_size, Labyrinth_size);
}
Labyrinth::Labyrinth()
{
cout<<"Loading Labyrinth... "<<endl;
/////PFAD ANPASSEN
// ifstream file ("/Users/Mathias/Desktop/map.raw", ios::in|ios::binary);
ifstream file ("map.raw", ios::in|ios::binary);
if (file.is_open())
{
file.read (reinterpret_cast<char *>( m_map), (sizeof(char)*Labyrinth_size*Labyrinth_size));
file.close();
}
else {
cout << "Unable to open file"<<endl;
createMaze();
m_map[0]=0;
}
}
bool Labyrinth::getMap() {
return m_map;
}
char Labyrinth::getBlock( int x, int y )
{
if(x > Labyrinth_size-1 || y > Labyrinth_size - 1)
return 1;
if(x < 0 || y < 0)
return 1;
return m_map[x+Labyrinth_size*y];
}
bool Labyrinth::hasBlock( int x, int y )
{
if(getBlock(x,y)==0)
return false;
else
return true;
}