SFML community forums
Help => General => Topic started by: enigma22134 on September 06, 2015, 04:44:08 pm
-
Hey guys,
When I resize my window to full screen, my game runs a bit slower.
That's fine, but I was wondering if there was any way to cap the speed my game runs at a minimized screen so that it will not be faster than it running as a full screen.
I thought about putting a pause-like statement in my game loop, but I wonder if there was a better way to do this?
-
http://www.sfml-dev.org/documentation/2.3/classsf_1_1Window.php#af4322d315baf93405bf0d5087ad5e784
You probably also want to read this: http://gafferongames.com/game-physics/fix-your-timestep/
-
One option I've seen some games do is simply pause the game while the window is being resized, until the user unpauses. Personally, I think that's a good option.
-
@dabbertorres, how does one test to see if the window is being resized?
I would say that using the timestep methods shows in Jesper's second link and pausing if the time accumulated becoming too large would be a decent choice here.
(Jesper answered the actual question fully, by the way ;D)
-
@dabbertorres, how does one test to see if the window is being resized?
http://www.sfml-dev.org/documentation/2.3/structsf_1_1Event_1_1SizeEvent.php
A resize event is generated on the first size change of the window iirc. If not, then handle a MouseLeft event. Different event, but same result generally. I know it's one of those, as I've done it before.
Though it looks like I completely misunderstood the question now that I've read it again, haha. I thought he was complaining about the game window lagging while resizing the window, my bad.
-
A resize event is generated on the first size change of the window iirc.
Ah, I see where your answer came from. However, the resize event is only generated once the resizing of the window has been completed.
-
Thanks for all the replies, they really helped! For now, I'm going to try and limit the frame rate. That seems like the quick fix, but I will probably have to get a bit more into it later.