hello everyone
so i'm trying to make a load map function and draw map function but i cant get it to work correctly, here is the code.
#include <SFML\Graphics.hpp>
#include <iostream>
#include <string>
#include <fstream>
int Map[100][100];
int loadCounterX=0;
int loadCounterY=0;
int mapSizeX;
int mapSizeY;
bool once=false;
void LoadMap (const char *filename)
{
std::ifstream openfile(filename);
if(openfile.is_open())
{
while(!openfile.eof())
{
if(once==false)
{
openfile>>mapSizeX>>mapSizeY;
once = true;
}
openfile >> Map[loadCounterX][loadCounterY];
loadCounterX++;
if(loadCounterX>=mapSizeX)
{
loadCounterX=0;
loadCounterY++;
}
}
}
}
void DrawMap()
{
for(int i=0; i<mapSizeX; i++)
for(int a=0; a<mapSizeY; a++)
Game.Draw(Map[i][a]);
}
int WindowWidth = 800, WindowHight = 600, ColorDepth = 32;
std::string WindowTitle = "The Final Game !!!";
sf::RenderWindow Game(sf::VideoMode(WindowWidth, WindowHight, ColorDepth), WindowTitle);
int main()
{
sf::Event Event;
const char *tiles[2];
tiles[1]=("Data/Images/grass.png");
tiles[2]=("Data/Images/dirt.png");
Game.SetFramerateLimit(60);
while(Game.IsOpened())
{
while(Game.GetEvent(Event))
{
}
Game.Clear();
Game.Display();
}
return 0;
}
text file
10 2
1111111111
0000000000