Post by Sylentdeath on Dec 10, 2014 19:06:55 GMT
Hi,
I'm trying to make a Titlemap loader who make a map using a file.
It's working well, but i see that it looks like when i'm picking a title in the map there something strange :
Using a sized title of 32x32 : When i pick a sprite at the 32*32 position on the map, I get the title on the first colmun and the second row.
Letting me think that picking on x axis tile limit <= 32
and picking on y axis title limit is < 32.
(Notice : That there no function to easily pick a title in a map using title index, so i use the sprite_by_position )
Note i fixed it why this modification
:
The filemap :
Map Loader is Under developpement.
I'm trying to make a Titlemap loader who make a map using a file.
It's working well, but i see that it looks like when i'm picking a title in the map there something strange :
Using a sized title of 32x32 : When i pick a sprite at the 32*32 position on the map, I get the title on the first colmun and the second row.
Letting me think that picking on x axis tile limit <= 32
and picking on y axis title limit is < 32.
(Notice : That there no function to easily pick a title in a map using title index, so i use the sprite_by_position )
Ness::TileMapPtr Load_Map(String filemap, Ness::ScenePtr &scene)
{
ifstream fichier(LevelsFolder + "Level1.txt", ios::in); // on ouvre le fichier en lecture
if(fichier) // si l'ouverture a réussi
{
// instructions
cout << "Fichier Ouvert" << endl;
stringstream buffer; //On va garder le fichier en mémoire
buffer << fichier.rdbuf(); // On le transfer dans le buffer
fichier.close(); // on ferme le fichier
cout << "Fichier Fermer" <<endl;
string line;
// TODO : Faire une classe
string AssetMapName;
int TSize;
int XSize;
int YSize;
int Rows;
int Cols;
int default_xpos;
int default_ypos;
// TODO : REFACTORISER !!!
getline(buffer, line);
while(line[0] == '#') // On cherche la premère ligne contenant des données
getline(buffer, line);
istringstream iss(line);
iss >> AssetMapName;
iss >> TSize;
iss >> XSize;
iss >> YSize;
iss >> Rows;
iss >> Cols;
iss.clear();
getline(buffer, line);
while(line[0] == '#')
getline(buffer, line);
iss.str(line);
iss >> default_xpos;
iss >> default_ypos;
iss.clear();
// create TileMap
const int TileSize = TSize; // <-- 32 is the size of a single tile in the spritesheet
const Ness::Pointi TilesInSpritesheet(XSize, YSize); // <-- 6 is how many tile types we got in the spritesheet on X axis, 16 is how many we got on Y axis
Ness::TileMapPtr map = scene->create_tilemap(TileMapFolder + AssetMapName, Ness::Sizei(Cols, Rows), Ness::Sizei(TSize, TSize));
// Assigning default Tile
map->set_all_tiles_type(Ness::Pointi(default_xpos,default_ypos), TilesInSpritesheet);
// Painting Map
vector<string> data = vector<string>();
getline(buffer, line);
while(line[0] == '#') // De meme toutes les lignes commencant par # sont ignorées
getline(buffer, line);
data = split(line, ';');
int xpos;
int ypos;
int i = 0;
for(int r=0; r < Rows; r++)
{
for(int c=0; c < Cols; c++)
{
xpos = atoi(&data[i][0]);
ypos = atoi(&data[i][2]);
map->get_sprite_by_position(Ness::Pointi(c*32,r*32))->set_source_from_sprite_sheet(Ness::Pointi(xpos,ypos), TilesInSpritesheet);
i++;
}
}
return map;
}
else // sinon
{
cerr << "Impossible d'ouvrir le fichier !" << endl;
}
return 0;
}
Note i fixed it why this modification
:
map->get_sprite_by_position(Ness::Pointi(c*32,((r*32)-1)))->set_source_from_sprite_sheet(Ness::Pointi(xpos,ypos), TilesInSpritesheet);
The filemap :
#Meta (Filename UnitTitleSize TitleMapColumns TitleMapRows MapRows MapColumns)
Tilemap.png 32 6 16 31 52
#Default Title to use
0-0
#Map Data
3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;2-0;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;3-3;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