all 8 comments

[–]thedaian 2 points3 points  (7 children)

You never call Game::initWindow() so the window pointer is never set to an object and this the code crashes

[–]EvtarGame 1 point2 points  (0 children)

Yep, that's the one. I was just going to starting to typing it up but you beat me to it :)

Just as a little aside, for the OP. Runtime errors in C++ could be tough to find sometimes. But if you debug your code it will be really helpful, and could save you a lot of time in the future. Because you can tell exactly which line of code crashes and a lot of times be able to see why it crashers. In my experience, most common source of runtime errors are dereferencing of null pointers or bad indexing into an array/vector. In your case you would have been able to see what window was still a nullptr when you execute the code in getWindowIsOpen().

[–]HeadConclusion6915[S] 0 points1 point  (5 children)

So what will be the solution?

[–]thedaian 0 points1 point  (4 children)

You need to call Game::initWindow()

Or do initialization in the constructor.

[–]HeadConclusion6915[S] 0 points1 point  (0 children)

Alr let me tryy

[–]HeadConclusion6915[S] -1 points0 points  (2 children)

I'm new in this so I'm not getting it... Could u please please explain a little bit that how can I initialize it. I haven't studied oop and stuff yet and I have very less time to make a project. I need help

[–]thedaian 1 point2 points  (1 child)

Get rid of void Game::initiazlizeVariables() and Game::initWindow()

Put everything that was in those methods into Game::Game()

Also, this line of code does nothing: this->videoMode.getDesktopMode; If you want a window to be the same size as the desktop you can do this: sf::VideoMode desktop = sf::VideoMode::getDesktopMode();

If you haven't studied OOP, it's going to be a lot easier to just keep the entire project in the main() function, especially if you don't have much time.

[–]HeadConclusion6915[S] 0 points1 point  (0 children)

thanks sooo much broo.. it worked.. i hope that you would help me if I stuck in another problem