Пример #1
0
bool MapLoader::loadMap() {
	std::ifstream infile{ "SpookyMap.txt" };
	std::string line;

	std::cout << "Loading map." << std::endl;

	while (std::getline(infile, line)) {
		if (line == "[header]") {
			std::cout << "Reading header." << std::endl;
			if (!readHeader(infile)) {
				return false;
			}
		}
		else if (line == "[layer]") {
			std::cout << "Reading Layer." << std::endl;
			readLayerData(infile);
		}
		else if (line == "[ObjectsLayer]"){
			std::cout << "Reading Entity." << std::endl;
			readEntityData(infile);
		}
	}

	return true;
}
Пример #2
0
void Level::readFile(std::ifstream& infile, GLuint& textureID) {
    std::string line;
    while (getline(infile, line)) {
        if (line == "[header]") {
            if(!readHeader(infile)) {
                return;
            }
        }
        else if(line == "[layer]") {
            readLayerData(infile);
        }
        else if(line == "[ObjectsLayer]") {
            readEntityData(infile);
        }
    }
}
Пример #3
0
void Tilemap::ReadFromFile( const std::string &path ) {
        // Do I feel guilty that I'm just ripping code from the slides?
        // A bit
        // Is C++ hard?
        // Yes.
        // Is it worth it to understand how game engines work games?
        // Yes.
        // Do I want to be using Unity right now?
        // Debug.log("Yes.");
    ifstream infile( path );
    string line;
    while (getline(infile, line)) {
        if(line == "[header]") {
            // I assume all my maps are the same size.
            // I do this because I was having issues with the levelData[x][y]
        } else if(line == "[layer]") {
            readLayerData(infile);
        } else if(line == "[Object Layer 1]") {
            readEntityData(infile);
        }
    }
}
Пример #4
0
void GameApp::BuildLevel()
{
	ifstream infile("tilemap.txt");
	string line;
	while (getline(infile, line)) 
	{
			if (line == "[header]") 
			{
				if (!readHeader(infile)) 
				{
					return;
				}
			}
			else if (line == "[layer]") 
			{
				readLayerData(infile);
			}
			else if (line == "[Object Layer 1]") 
			{
				readEntityData(infile);
			}
	}
}