Arch Game Engine  0.2
map.cpp
1 #include "map.h"
2 
3 Map::Map() {
4  startX = startY = 0;
5 }
6 Map::~Map() {}
7 
8 void Map::loadMap(string filename) {
9  ifstream in(filename.c_str());
10  if(!in.is_open()) {
11  cout << "Problem with loading the file" << endl;
12  return;
13  }
14  int w, h;
15  in >> w;
16  in >> h;
17  int current;
18  for(int i=0;i<h;i++) {
19  vector<int> row;
20  for(int j=0;j<w;j++) {
21  if(in.eof()) {
22  cout << "File end reached too soon" << endl;
23  return;
24  }
25  in >> current;
26  row.push_back(current);
27  }
28  map.push_back(row);
29  }
30  if(!in.eof()) {
31  in >> startX;
32  in >> startY;
33  }
34  in.close();
35 }
void loadMap(string filename)
Read in map file with given path to the file.
Definition: map.cpp:8