+ 2

Game loops

Can someone describe what is game loop and how it works?

1st Sep 2017, 6:27 PM
Ilias
Ilias - avatar
4 Respuestas
+ 4
do u loops in java , ...don't know about game open the lesson and learn urself ... a good explanation is provided there here is a code using loops https://code.sololearn.com/ccKOF9SAPH0P/?ref=app
1st Sep 2017, 6:36 PM
Changed
Changed - avatar
+ 2
You need to picture a game as a video or an animation to understand what the game loop does. As you may already know, a video or an animation is just moving pictures. Or lots of pictures where each picture is different from the next to create the illusion that the picture is moving. These different pictures are also called frames in a video or animation and are usually set at a speed of 60 frames per second. This creates a smooth animation. Now the game loop is just a loop function where all the changes in frames, for the game you're making, takes place. Take a look at this code of mine, in this code, the function called "runtime" (line 259) is my game's game loop. It's not a loop function on it's own but there's a "setInterval" (line 296) function that controls it and sets it's speed. Try playing around with this code. https://code.sololearn.com/WGlDfqT0U0IO/?ref=app
1st Sep 2017, 6:51 PM
Ghauth Christians
Ghauth Christians - avatar
0
The main game loop is the entry point of game programs. Every frame, it does things like handling user input and updating/rendering game entities.
1st Sep 2017, 6:35 PM
Daniel de Lizaur
0
You need a game loop if you dont want the program to end. You see, if you write a normal program it would just execute one line after the other and would reach the end after some time. You dont want this to happen in a game, so thats what the game loop does, it prevents the program from running through abd handles the logic of your game, as said above
1st Sep 2017, 7:43 PM
Elias
Elias - avatar