Questions tagged [game-loop]

The central component of any game, from a programming standpoint, is the game loop. The game loop allows the game to run smoothly regardless of a user's input or lack thereof.

The game loop is the central component of any game and it is generally split into three different pieces: initialization, update, and draw (or render).

During the initialization phase, the game is set up and the environment is prepared for the update and draw routines.

During the update phase, all of the objects and components of the game are updated based on the game's logic, user's input and the time since the last update routine.

During the draw or render phase, all of the objects and components of the game are drawn or rendered to the viewport based on the most recent update.

Once the current frame is rendered, the game loop repeats the execution of the update statements based on the new delta time and then renders again.

485 questions
0
votes
1 answer

Which Container to choose?

I'm not really sure this question really is about containers, please bear with me. A game has 'turns' that are incremented, there is no Timer that fires at a certain time. Now there is also a large bucket of objects, where some of them need updating…
Bersaelor
  • 2,517
  • 34
  • 58
0
votes
1 answer

Constructor wont run it's code

I want to run a gameloop code inside my GameLoop class constructor in my activity, but it seems that it got no respond. I've tried to put the code inside the OnCreate method instead of a new class and that worked. My Activiy Class: public class…
0
votes
3 answers

Best Way to Perform Event Once During Game Loop?

In a game scenario, where you have an update() method is called 30 times a second, what would be the best way to do something once? For example, if you were adding an entity into the scene: public void update() { Entity e = new Entity(32, 32,…
sparklyllama
  • 1,276
  • 4
  • 20
  • 28
0
votes
1 answer

How to scroll background in games?

I have some basic programming skills but Im new in game programming. Know that every game needs a game loop, something like while (true) { //do things } in separate thread. But i wonder how is a scrollabe background (2D) used to be realized (when…
Iriminage
  • 177
  • 2
  • 17
0
votes
1 answer

Delta time not being calculated properly

I am trying to create a game in which objects spawn on a timer then start moving. I would like to keep the frame rate independent of the game speed, so I have tried to implement delta time: lastTime = thisTime; thisTime = (int)…
Zach H
  • 257
  • 1
  • 3
  • 15
0
votes
1 answer

Problems with Android Gameloop (openGL ES 2.0)

Overview Having a lot of problem with choppy animations in my game loop. I'm running the loop from onDrawFrame and as you can see, my loop allows for frame skipping if it takes too long (I'm using a fixed time delta and my time 'slice' for 60fps…
Zippy
  • 3,826
  • 5
  • 43
  • 96
0
votes
1 answer

Game loop design - (dis)advantages of limiting the fps

I am trying to understand the different ways of how to implement game loops and their advantages and disadvantages. While researching, I found this: http://entropyinteractive.com/2011/02/game-engine-design-the-game-loop/ But here is on thing that I…
Vulpecula
  • 135
  • 1
  • 10
0
votes
4 answers

Implementing Delta timing in my loop

I want to implement delta timing in my SFML loop in order to compensate for other computers that choose to run my application, right now I just have float delta = .06 placed before my loop, but as wikipedia describes delta timing: It is done by…
Syntactic Fructose
  • 18,936
  • 23
  • 91
  • 177
0
votes
1 answer

Why is SDL_Flip not limiting the FPS to match screen frequency?

I'm using SDL 1.2 and VS2008 for a smaller game-like application. I have recently (after getting some ideas from other posts on SO which i cannot find now, so sorry if you feel i should have linked your question for reference) re-written my…
Martin G
  • 17,357
  • 9
  • 82
  • 98
0
votes
1 answer

Understanding Interpolation

I have been reading up on game loops and am having a hard time understanding the concept of interpolation. From what I seen so far, a high level game loop design should look something like the sample below. ASSUME WE WANT OUR LOOP TO TAKE 50…
Jason
  • 1,371
  • 4
  • 21
  • 44
0
votes
2 answers

constant framerate Gameloop using System.Diagnostics.Stopwatch and delta time in C# from tutorial

I picked up a tutorial on how to do a game loop where the framerate is always the same no matter how big the rendering space gets or the speed of your CPU. It involves using a time interval, but I've poured over this a hundred times and I can not…
0
votes
0 answers

Java weird render on images

Allow me to begin by mentioning my description may not be completely understandable. I honestly have trouble finding the words to describe this problem, so I compiled my code into a executable jar you may run to try to understand what I am saying.…
Evan Nudd
  • 216
  • 2
  • 10
0
votes
1 answer

How to call my gameloop throughout entire program and what to put in tick()

Ok so sorry if this is a noob question, but this is the first time making a game and I just want to know how to call in the gameloop, I have it created in my Keylistener class, but whenever I run it it just freezes due to an infiniate while loop in…
0
votes
2 answers

FPS camera rotating by itself. QT 4.8 + OpenGL + C++

I'm trying to port my height map visualization program written on c++, from SFML to Qt, so it can be shown on widget and controlled by the GUI elements. The problem is that when I start an application, a camera starts to roll around its center very…
Russel Ledge
  • 221
  • 3
  • 11
0
votes
1 answer

How can I make this Java program loop?

I'm a newbie at programming and I need to add a JOptionPane that says: "Play again?". With "Yes" and "No" as the options. If "Yes", the game will start again. If "No", the game will terminate. Any help would be much appreciated. Thanks in advance!…