I actually forgot to change something.
TileMap::TileMap()
{
App = new sf::RenderWindow(sf::VideoMode(1088, 832), MapType + " - " + MapName);
App2 = new sf::RenderWindow(sf::VideoMode(64, 640), "Images");
}
Should be
TileMap::TileMap()
{
App = &sf::RenderWindow(sf::VideoMode(1088, 832), MapType + " - " + MapName);
App2 = &sf::RenderWindow(sf::VideoMode(64, 640), "Images");
}
And that's what I'm getting an error with. The rest of my code(Minus unrelated functions, of course):
class TileMap
{
public:
sf::RenderWindow* App;
sf::RenderWindow* App2;
sf::View View;
vector<int> MapData;
vector<sf::Sprite> Sprites;
vector<sf::Image> Images;
vector<sf::Shape> Shapes;
vector<string> MapTypes;
int MapWidth, MapHeight, ImageSize;
string MapType, MapName;
//void Draw(int, int, int);//Done
void Inputs();
void Inputs(vector<TileMap>&);//Done
void LoadImages();//Done
void LoadSprites();//Done
void SaveFile();//Done
void LoadFile();//Done
void GetEvents();//Done
void Display();
void Display(vector<sf::Sprite>&, vector<int>&);
//void SaveCalc();
//void SendCalc();//This will be the last thing to be implemented
TileMap();//Type of Map
//TileMap(string, string);
//~TileMap();
protected:
private:
int ImgListNum, selectedimage, selectedimage2;
};
int main()
{
vector<TileMap> Maps;
Maps.push_back(TileMap());
while(Maps[0].App -> IsOpened())
{
for(int i = 0; i < Maps.size(); i++)
{
Maps[i].GetEvents();
if(!Maps[i].App -> IsOpened())
Maps.erase(Maps.begin() + i);
Maps[i].Inputs(Maps);
Maps[i].App -> Clear();
Maps[i].App2 -> Clear(sf::Color::White);
if(Maps[i].MapType == "visual")
Maps[i].Display();
else
Maps[i].Display(Maps[0].Sprites, Maps[0].MapData);
}
}
return 0;
}
TileMap::TileMap()
{
bool load = false;
MapTypes.push_back("visual");
MapTypes.push_back("collision");
MapTypes.push_back("transitional");
MapTypes.push_back("events");
MapTypes.push_back("NPC");
int choice = -1;
while(choice < 0 || choice > MapTypes.size())
{
system("cls");
cout << "Map Type";
for(int i = 0; i < MapTypes.size(); i++)
cout << "\n" << i << ":\t" << MapTypes[i];
cout << "\n(1, 2, 3, 4...): ";
cin >> choice;
}
MapType = MapTypes[choice];
cout << "Do you want to load a map? (1/0)";
cin >> load;
if(load)
{
cout << "Name of Map to Load: ";
cin >> MapName;
}
else
{
cout << "Name of New Map: ";
cin >> MapName;
cout << "Input Map Size (X Y): ";
cin >> MapWidth >> MapHeight;
MapData.resize(MapWidth * MapHeight, -1);
}
cout << "Input Image Size: ";
cin >> ImageSize;
App = &sf::RenderWindow(sf::VideoMode(1088, 832), MapType + " - " + MapName);
App2 = &sf::RenderWindow(sf::VideoMode(64, 640), "Images");
App -> UseVerticalSync(true);
App2 -> UseVerticalSync(true);
View.SetFromRect(sf::FloatRect(0,0,1088,832));
App -> SetView(View);
LoadImages();
cout << "Images Loaded\n";
LoadSprites();
cout << "Sprites Loaded\n";
selectedimage = 0;
selectedimage2 = 1;
Shapes.push_back(sf::Shape::Rectangle(0,0,(MapWidth * ImageSize), (MapHeight * ImageSize),sf::Color(255,255,255,0),4,sf::Color(0,0,255,127)));
Shapes.push_back(sf::Shape::Rectangle(0,0,ImageSize,ImageSize,sf::Color(255,255,255,0),4,sf::Color(0,0,255,127)));
Shapes.push_back(sf::Shape::Rectangle(0,0,ImageSize,ImageSize,sf::Color(255,255,255,0),4,sf::Color(0,255,0,127)));
}