Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
122 votes
Accepted

What is the point of update independent rendering in a game loop?

There's a long history of how we arrived at this common convention, with lots of fascinating challenges along the way, so I'll try to motivate it in stages: 1. Problem: Devices run at different ...
user avatar
  • 113k
42 votes
Accepted

Why does my sprite player move faster when I move the mouse?

tl;dr don't mix your event loop with your game loop. When you move your mouse, the game receives a load of pygame.MOUSEMOTION events. You don't actually use these ...
user avatar
  • 14.5k
34 votes
Accepted

Is there any harm in having the main game loop run uncontrolled?

It will cause one CPU core to always run on 100%. This usually doesn't cause any harm to the system. CPUs are designed to run on 100% for hours. But on a mobile device it will drain the battery ...
user avatar
  • 111k
31 votes
Accepted

Fixed timestep game loop, why interpolation

Some games do indeed extrapolate. An advantage of extrapolation is that you can do it with just the single most recent state and a rate of change (like velocity, angular velocity, etc.) rather than ...
user avatar
  • 113k
21 votes
Accepted

Pausing the game inside the game loop

Don't actually stop the game loop when pausing the game. Instead, you have to add bool variable, that is changed to true/false depending if game is paused. If game is paused, you only have to stop ...
user avatar
  • 2,102
17 votes

OpenGL - How come drawing sprites takes so much performance

Your GPU can probably render even 100k sprites without issues, but you need to do it smart. Sprites and other geometry must be supplied to a GPU in batches grouped by the same texture, shader and ...
user avatar
  • 308
13 votes

How can City-sim simulate hundreds of characters?

Like so much of gamedev, the answer to how city sim games accomplish this seemingly-impossible feat is: they probably don't. They're just faking it well. ;) Sims like these will typically operate on a ...
user avatar
  • 113k
11 votes
Accepted

What's the difference between Update and FixedUpdate in Unity, and should I bother?

FixedUpdate can run faster or slower than Update depending on your settings. That'll depend on load (how fast ...
user avatar
  • 72.7k
10 votes
Accepted

UPS and FPS - What should I limit and why?

Yes, it does make sense. As you said it will make less load on the system, which is good for thermals, and other applications. However.... Your games logic should NOT depend on the updates per ...
user avatar
  • 1,943
9 votes
Accepted

Pro's/Con's of separating game logic and render threads

In a word, synchronization. If you have some data (your world) which you're reading from one thread (the rendering thread), and writing to in another thread (the logic thread), it is possible that ...
user avatar
  • 13.2k
9 votes

What is the relationship between Frames-Per-Second and a game loop?

Typically, a frame is drawn every time through the game loop. Thus, the FPS tells you how fast the game is looping. That said, more sophisticated rendering architectures often decouple the rendering ...
user avatar
  • 15.6k
8 votes

What is the point of update independent rendering in a game loop?

The other answers are good and talk about why the game loop exists and should be seperate from the render loop. However, as for the specific example of "Why render a frame when there hasn't been any ...
user avatar
  • 201
7 votes

What's the difference between Update and FixedUpdate in Unity, and should I bother?

You need to understand what each one does. Update() gets called as often as possible (not sure, maybe it can be capped), either way - each frame. ...
user avatar
  • 2,214
7 votes
Accepted

How can I implement a main menu?

As congusbongus notes in his answer, many games benefit from dividing content into "scenes". A scene might represent a particular level, a room, a minigame, or lots of other possibilities, depending ...
user avatar
  • 2,308
7 votes
Accepted

Game Update in Libgdx

There is no specific game loop in libGDX because it is event-driven. And still, you can see the render method as the main loop. You've got it right - usually, this is where you update the game logic ...
user avatar
7 votes

Frameskipping in Android gameloop causing choppy sprites (Open GL ES 2.0)

From what I see, the game loops you are trying to use are somewhat specialized. I don't know why you chose those ones, but in my opinion you are trying to solve problems that don't exist in the first ...
user avatar
  • 13.2k
7 votes
Accepted

Game Loop design that is speed hack proof

You can't. Whatever code runs on the computer owned by the user is under the users control. Anything you program can be circumvented or patched by a determined enough hacker. The only solution to ...
user avatar
  • 111k
7 votes

How and when should I update events occuring after a while?

Store your birthday and calculate your age on demand. When I buy alcohol the shopkeeper sometimes checks my ID to make sure I am not underage. However, my ID card doesn't have my actual age, and I ...
user avatar
  • 14.5k
7 votes
Accepted

C++ Object management/deletion

You're using a std::vector<Bullet>. This has the advantage of keeping data contiguous in memory, so iterating over it is fast (it has something to do with ...
user avatar
  • 15.4k
6 votes
Accepted

How do I implement a fixed delta time step with a SDL_Delay(15ms) precision

You can't reliably control the FPS with functions like SDL_Delay, they call the operating sleep function, which tells the operating system "Please don't give me any CPU time for at least N miliseconds"...
user avatar
  • 3,203
6 votes
Accepted

render/draw or input first?

When writing your main loop and updating logic, you've got two basic strategies, which you're probably aware of: fixed time steps and dynamic time steps. Either way your updates will happen at some ...
user avatar
  • 8,272
6 votes

UPS and FPS - What should I limit and why?

The best answer is: It depends. You don't have to limit neither one Updates: If your updates are not bound to an upper limit, then game logic should be dependent on a delta time amount, to avoid ...
user avatar
  • 3,017
6 votes

Varying framerate (FPS)

Temporal Aliasing As Andon M. Coleman is stating out in the comments what you describe is called temporal aliasing. Temporal aliasing is due to a too low sampling rate of the scene compared to the ...
user avatar
  • 213
6 votes
Accepted

Game Loop getting 58-62 FPS. Why not exactly 60FPS? (SDL/C++/OSX)

SDL_Delay() doesn't really have fidelity of any sort; it puts your main thread to sleep, and once your thread is sleeping it's up to the OS to decide when to wake ...
user avatar
6 votes

What is the point of update independent rendering in a game loop?

Rendering is usually the slowest process in the game loop. Humans don't easily notice a difference in a frame rate faster than 60, so it often less important to waste time on rendering faster than ...
user avatar
  • 2,586
6 votes
Accepted

Can I always assume that fixed time step in Unity is reliable?

I've done some tests simulating low framerate conditions, and empirically confirmed that the deltaTime value for each FixedUpdate step does indeed stay consistent. ...
user avatar
  • 113k
6 votes
Accepted

How and when should I update events occuring after a while?

Another approach for handling events on a larger time scale is using a Heap. In short, a Heap is a binary tree that always brings the largest or smallest item to the top. If you maintain a min-heap (...
user avatar
  • 1,330

Only top scored, non community-wiki answers of a minimum length are eligible