Ok, so I think my problem here has a little less to do with SFML and a bit more to do with C++, but no matter.
I'm trying to draw a character sprite from a class, but this code seems to freeze the program.
I wrote a game class that essentially is the state pattern, but it also runs a window. And for the actual level [ being run in GameLoop() ], I've created a character that should appear and fall. However, it seems to freeze before it even gets there, not even succeeding at clearing the window before it switches states.
However, I've tested that code and it doesn't seem to be the problem. The problem only occurs in GameLoop, and I presume it's because of how I'm using the draw() function here:
void Game::GameLoop ()
{
// We already set up the window. Everything that occurs will be inside the window.
//I'm gonna write some code for this and link it to the title loop.
Character Character;
while (GameState == TestRoom);
{
Character.UpdatePosition();
Window.draw(Character.Shantae);
Window.display();
}
}
I knew it was bad coding practice, but I didn't think it would be a big deal to make "Shantae" (the sprite, of course) temporarily public. Anyway, I'm not sure what's the best way to access this sprite so that I can use window.draw() without errors. Here's a bit of the Character class, by the way:
class Character
{
public:
//UpdatePosition is going to check for all movement starting with falling. We can call it from within the game loop.
void UpdatePosition();
Character();
sf::Sprite Shantae;
};
Thanks for any help, you guys.