Ive been having alot of trouble getting sprites into a vector , this is the code ive been using ,and i keep getting an error as i try and access clipped[60] to set the position of that sprite, and also when trying to draw it. #include "tile.h"
Tile::Tile()
{
sf::Image tileset;
sf::Sprite sprit;
vector<sf::Sprite> clipped;
tileset.LoadFromFile("C:/Users/stubbs/Desktop/tilesheet.png");
tileset.SetSmooth(false);
sprit.SetImage(tileset);
for(int x = 0; x <= 7; x++)
{
for(int y = 0; y <= 20; y++)
{
sprit.SetSubRect(sf::IntRect(x,y*16,x+16,y+16));
clipped.push_back(sprit);
}
}
}
void Tile::SetType(sf::RenderWindow &App)
{
for(int x = 0; x <= 30; x++)
{
for(int y = 0; y <= 30; y++)
{
clipped[60].SetPosition((x*16),(y*16));
App.Draw(clipped[60]);
}
}
}
so what im trying to do is cut my sprite sheet into 16x16 squares and load each into a vector. so i will be able to assign what type of tile goes where.
any help would be great.