Program napisany z wykorzystaniem sfml w c++.
Mam klasę Platform
class Platform{
public:
Platform();
~Platform();
std::vector<sf::Sprite> create_platforms(sf::Texture &texture);
sf::Sprite create_ground(sf::Texture &ground_texture);
private:
sf::Vector2u platform_pos[20];
std::vector<sf::Sprite> platforms;
sf::Sprite ground;
};
sf::Sprite Platform::create_ground(sf::Texture &ground_texture)
{ ground.setTexture(ground_texture);
ground.setTextureRect(sf::IntRect(0, 50, 50, 50));
return ground;}
Gdy próbuję wywołać w mainie funkcję create_ground() program się kompiluje, ale nie można ruszać postacią.i po sekundzie się wyłącza.
sf::Texture ground_texture;
ground_texture.setRepeated(true);
ground_texture.loadFromFile("grass.png");
sf::Sprite ground = platform.create_ground(ground_texture);
Przy wywołaniu create_platforms() program działa poprawnie, a napisane są praktycznie tak samo. Program jest podzielony na pliki. Myślę, że może chodzić właśnie o podział plików, ale proszę o pomoc.