- while(file >> line)
- {
- words.push_back(line);
- }
- for(int i = 0; i < words.size(); i++)
- {
- if(words.at(i).substr(0, 1) == "[" && words.at(i) != "[header]")
- layers.push_back(words.at(i));
- if(words.at(i).substr(0, 4) == "type")
- {
- temp = words.at(i);
- temp.substr(4, 1);
- types.push_back(temp);
- }
- if(words.at(i) == "[header]")
- {
- map_width = words.at(i+1).substr(6, words.at(i+1).size());
- map_height = words.at(i+2).substr(7, words.at(i+1).size());
- stringstream(map_width) >> width;
- stringstream(map_height) >> height;
- }
- if(words.at(i) == "type=background")
- {
- for(int j = i+1; j <= height + (i+1); j++)
- {
- int l = 0, m = 1, number = 0, extracted;
- string extracted_line = words.at(j);
- for(int k = 0; k <= extracted_line.size(); k++)
- {
- cout << number << endl;
- string ph_character = words.at(j).substr(l, m);
- if(ph_character == ",")
- {
- number = 0;
- break;
- }
- if(ph_character == "0") cout << "Found 0.\n";
- stringstream(ph_character) >> extracted;
- number = (number*10) + extracted;
- switch(number)
- {
- case 1:
- //cout << "Found 1" << endl;
- break;
- case 4:
- cout << "Found 4" << endl;
- break;
- }
- l++; m++;
- }
- }
- }
- }
- file.close();
- }