Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
General
»
Help with Game Loop
Print
Pages: [
1
]
Author
Topic: Help with Game Loop (Read 1335 times)
0 Members and 1 Guest are viewing this topic.
Sanction
Jr. Member
Posts: 63
Help with Game Loop
«
on:
October 06, 2016, 05:27:02 pm »
So I was working on game states a few weeks ago and I couldn't get the game states to transition. after look at the code and walking threw it, I never render I'm stuck within my loop and I don't remember what I changed.
Can anyone see what is wrong with this game loop? I'm stuck in the nested while loop.
(click to show/hide)
sf
::
Clock
clock
;
_deltaTime
=
clock
.
getElapsedTime
(
)
;
while
(
_window
-
>
isOpen
(
)
)
{
_deltaTime
+
=
clock
.
restart
(
)
;
while
(
_deltaTime.
asSeconds
(
)
>=
_frameTime
)
{
if
(
currentState
(
)
==
nullptr
)
continue
;
currentState
(
)
-
>
handleInput
(
)
;
currentState
(
)
-
>
update
(
_deltaTime
)
;
_deltaTime
+
=
clock
.
restart
(
)
;
}
//_CollisionSystem->update(_entities);
//_LevelManager->update(_deltaTime);
currentState
(
)
-
>
render
(
_deltaTime
)
;
}
Logged
Knowledge comes, but wisdom lingers. It may not be difficult to store up in the mind a vast quantity of facts within a comparatively short time, but the ability to form judgments requires the severe discipline of hard work and the tempering heat of experience and maturity.
Laurent
Administrator
Hero Member
Posts: 32504
Re: Help with Game Loop
«
Reply #1 on:
October 06, 2016, 05:38:23 pm »
currentState() == nullptr maybe?
Otherwise just execute your code step by step, watch the value of the variables involved in the condition, and simply see what happens.
Logged
Laurent Gomila - SFML developer
Print
Pages: [
1
]
SFML community forums
»
Help
»
General
»
Help with Game Loop