Overworld/State.cpp
void State::save(const std::string& filename) {
	//open file and deal with errors if cannot
	std::ofstream outputFile;
	outputFile.open(filename, std::ios::out | std::ios::binary);
	if (!outputFile) {
		std::cout << "file could not be opened.\n";
		return;
	}
	
	//write current position and which map you're on
	sf::Vector2f position = player->getPosition();
	outputFile.write((char*)&position.x, sizeof(float));
	outputFile.write((char*)&position.y, sizeof(float));
	std::cout << "Position recorded: " << position.x << ", " << position.y << "\n";
	std::cout << "Player at: " << player->getBase() << "\n";
	//	outputFile.write((char*)currentMap->ID, sizeof(int));
	
	//write all current conditions
	for(auto condition : this->conditions) {
		outputFile.write((char*)&condition, sizeof(int));
	}
	
	outputFile.close();
	std::cout << "Save completed successfully.\n";
}
//this is not where save should be, but I'm putting it here for now, so that I can refer to it
this is not where save should be, but I'm putting it here for now, so that I can refer to it
this is not where save should be but I ' m putting it here for now so that I can refer to it
void State::save(const std::string& filename) {
	std::ofstream outputFile;
	outputFile.open(filename, std::ios::out | std::ios::binary);
	if (!outputFile) {
		std::cout << "file could not be opened.\n";
		return;
	}
	sf::Vector2f position = player->getPosition();
	outputFile.write((char*)&position.x, sizeof(float));
	outputFile.write((char*)&position.y, sizeof(float));
	std::cout << "Position recorded: " << position.x << ", " << position.y << "\n";
	std::cout << "Player at: " << player->getBase() << "\n";
	for(auto condition : this->conditions) {
		outputFile.write((char*)&condition, sizeof(int));
	}
	outputFile.close();
	std::cout << "Save completed successfully.\n";
}
void State :: save ( const std :: string & filename ) { std :: ofstream outputFile ; outputFile . open ( filename , std :: ios :: out | std :: ios :: binary ) ; if ( ! outputFile ) { std :: cout << " \n " ; return ; } sf :: Vector2f position = player -> getPosition ( ) ; outputFile . write ( ( char * ) & position . x , sizeof ( float ) ) ; outputFile . write ( ( char * ) & position . y , sizeof ( float ) ) ; std :: cout << " " << position . x << " " << position . y << " \n " ; std :: cout << " " << player -> getBase ( ) << " \n " ; for ( auto condition : this -> conditions ) { outputFile . write ( ( char * ) & condition , sizeof ( int ) ) ; } outputFile . close ( ) ; std :: cout << " \n " ; }
this is not where save should be, but I'm putting it here for now, so that I can refer to it
this is not where save should be but I ' m putting it here for now so that I can refer to it
//open file and deal with errors if cannot //write current position and which map you're on //	outputFile.write((char*)currentMap->ID, sizeof(int)); //write all current conditions