Hey,
I had a class for each Tile and a Vector for all Tiles.
Here are the code.
The Problem is that i get white Objects ?
#pragma once
#include <string>
#include <SFML\Graphics.hpp>
class tile {
public:
tile(std::string Path, float X, float Y, float Rotation, bool bCollision);
~tile();
public:
float X, Y, Rotation;
bool Collision;
sf::Sprite sTile;
sf::Image iTile;
};
#include "tile.h"
tile::tile(std::string Path, float X, float Y, float Rotation, bool bCollision){
iTile.LoadFromFile(Path);
iTile.SetSmooth(false);
sTile.SetImage(iTile);
sTile.SetRotation(Rotation);
sTile.SetPosition(X,Y);
sTile.SetCenter(16,16);
Collision = bCollision;
}
tile::~tile(){
}
std::vector<tile> Map;
//LoadMap
char *FileMap;
std::string CurLine;
int iCurLine = 0;
ifstream file("./data/map1.bsm");
while(getline(file, CurLine)){
iCurLine++;
FileMap = strtok(const_cast<char*>(CurLine.c_str()),"|");
int BuildUp = 0;
string Type;
float PosX, PosY, Angle;
bool Colide;
while (FileMap != NULL){
if(BuildUp == 0){
if(toStr(FileMap) == "sand"){
Type = "./data/sand.png";
}else if(toStr(FileMap) == "wall"){
Type = "./data/wall.png";
}else if(toStr(FileMap) == "walledge"){
Type = "./data/walledge.png";
}
}else if(BuildUp == 1){
PosX = atof(FileMap);
}else if(BuildUp == 2){
PosY = atof(FileMap);
}else if(BuildUp == 3){
Angle = atof(FileMap);
}else if(BuildUp == 4){
if(toStr(FileMap) == "true"){
Colide = true;
}else{
Colide = false;
}
}
BuildUp++;
FileMap = strtok (NULL, "|");
}
tile TempTile123(Type,PosX,PosY,Angle,Colide);
Map.push_back(TempTile123);
}
And the map1.bsm
sand|32.0f|32.0f|0.0f|false
wall|200.0f|200.0f|45.0f|true
sand|32.0f|32.0f|0.0f|false