std::vector<sf::Sprite> loadSprites(std::string name,
int width = 64,
int height = 64,
int alpha = 255,
bool transparent = false){
std::vector<sf::Sprite> vec;
sf::Image spbase;
sf::Texture tx;
sf::IntRect area;
if(!spbase.loadFromFile(name)){
return vec;
}
if(transparent){
sf::Color c = spbase.getPixel(0, 0);
c.a = alpha;
spbase.setPixel(0, 0, c);
}
for(int y = 0; y < spbase.getSize().y; y+= height){
for(int x = 0; x < spbase.getSize().x; x += width){
area = sf::IntRect(x, y, width, height);
tx.loadFromImage(spbase, area);
vec.push_back(sf::Sprite(tx));
}
}
}
c3RkOjp2ZWN0b3I8c2Y6OlNwcml0ZT4gbG9hZFNwcml0ZXMoc3RkOjpzdHJpbmcgbmFtZSwKICAgIGludCB3aWR0aCA9IDY0LAogICAgaW50IGhlaWdodCA9IDY0LAogICAgaW50IGFscGhhID0gMjU1LAogICAgYm9vbCB0cmFuc3BhcmVudCA9IGZhbHNlKXsKCiAgICBzdGQ6OnZlY3RvcjxzZjo6U3ByaXRlPiB2ZWM7CiAgICBzZjo6SW1hZ2UJc3BiYXNlOwogICAgc2Y6OlRleHR1cmUgdHg7CiAgICBzZjo6SW50UmVjdAlhcmVhOwoKICAgIGlmKCFzcGJhc2UubG9hZEZyb21GaWxlKG5hbWUpKXsKCiAgICAgICAgcmV0dXJuIHZlYzsKICAgIH0KCiAgICBpZih0cmFuc3BhcmVudCl7CgogICAgICAgIHNmOjpDb2xvciBjID0gc3BiYXNlLmdldFBpeGVsKDAsIDApOwogICAgICAgIGMuYSA9IGFscGhhOwogICAgICAgIHNwYmFzZS5zZXRQaXhlbCgwLCAwLCBjKTsKICAgIH0KCiAgICBmb3IoaW50IHkgPSAwOyB5IDwgc3BiYXNlLmdldFNpemUoKS55OyB5Kz0gaGVpZ2h0KXsKICAgICAgICBmb3IoaW50IHggPSAwOyB4IDwgc3BiYXNlLmdldFNpemUoKS54OyB4ICs9IHdpZHRoKXsKCiAgICAgICAgICAgIGFyZWEgPSBzZjo6SW50UmVjdCh4LCB5LCB3aWR0aCwgaGVpZ2h0KTsKCQkJCQogICAgICAgICAgICB0eC5sb2FkRnJvbUltYWdlKHNwYmFzZSwgYXJlYSk7CiAgICAgICAgICAgIHZlYy5wdXNoX2JhY2soc2Y6OlNwcml0ZSh0eCkpOwogICAgICAgIH0KICAgIH0KfQ==