Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: app.Create () crashes program  (Read 1757 times)

0 Members and 1 Guest are viewing this topic.

cristi121

  • Newbie
  • *
  • Posts: 33
    • View Profile
app.Create () crashes program
« on: March 28, 2011, 07:04:54 pm »
Hello!

I'm making a simple TicTacToe game, and I'm having some problems with the graphics.

I've written a class containing everything I need:

Code: [Select]

class Game
{
    public:

            Game();

            ~Game();

           //boring stuff

    private:

            bool turn;                    // 1 for x, 0 for O

            int board[4][4];              // 1 for x, -1 for 0, 0 for avaiblable square

            sf::RenderWindow app;

};

Game::Game()
{
    //more boring stuff

    cout << "enter";   //This is printed
    app.Create(sf::VideoMode (800,600,32) , "TicTacToe");
    cout << "exit";     //This is not printed
}



The code runs fine without the RenderWindow, but when I add it the program just crashes ( "TicTacToe.exe has stopped working" ). To be more exact, first the console shows, then the window shows, then it stays like this for a few seconds and only after that it crashes.
What am I doing wrong?

Thank you. :)

Edit:
I forgot to mention. After I close the window, the program returns -1073741819.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
app.Create () crashes program
« Reply #1 on: March 28, 2011, 08:55:45 pm »
I don't see a mistake in your code. Reduce it to a minimal and complete example that still reproduces the problem. Like this, we can be sure that there are no side-effects resulting from your project-specific stuff.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

cristi121

  • Newbie
  • *
  • Posts: 33
    • View Profile
app.Create () crashes program
« Reply #2 on: March 29, 2011, 02:54:07 pm »
Thank for your answer.

I just managed to fix it myself, it had nothing to do with SFML.
I had an int board[4][4], and the constructor initilized board[4][4], which doesn't exist.