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
1
vote
2 answers

Time-efficient Gameloop in J2ME

I've done a series of questions about J2ME Game developing, and in a recent one, Neil Coffey commented As a side issue-- do you REALLY want to do 100 ticks/second in a J2ME game? As I think sb has mentioned, you should really also sleep to…
fixmycode
  • 8,220
  • 2
  • 28
  • 43
1
vote
1 answer

In-App Purchase hold game loop

On my iPhone/iPad game app, when users touch on buy/purchase button, a dialog of in-app purchase is popping up and the whole game loop is stuck. I would like the game loop still updating while in-app purchase is processing. Please someone point me…
Plus Pingya
  • 171
  • 8
0
votes
1 answer

Seeking help in a basic, bare bones method of creating a 2D OpenGL-ES 2.0 Game

I have made many Android applications that use Java code and the XML layouts, however I am very new to OpenGL ES. I have programmed games in Swing Java, including pong, and an intermediate level 2d platformer (with a map editor, too!). I have…
Qasim
  • 1,686
  • 4
  • 27
  • 51
0
votes
2 answers

What is wrong with this applet gameloop?

It seems like this applet will only draw and update DRAWS when the window is resized or minimized. So the applet will not repaint all the time, but only when manipulating the window. Am I doing something wrong here? I am following the gameloop…
SCH
  • 13
  • 4
0
votes
1 answer

Android gameloop, update and draw separate or not?

I'm just picking up android development to make a game. Touched it before, but only picked up the basics. I'm a bit confused how to set up a main loop. I've been into XNA (C#) and I love the separated update/draw loop. I was wondering how a typical…
omgnoseat
  • 361
  • 2
  • 19
0
votes
2 answers

Game main loop logic

I'm writing a game in c++ using allegro 5. Allegro 5 has events which are stacked in an event queue(like mouse clicked or timer ticked after 1/FSP time). So my question is how should be the logic of the main loop of my game, or since it's event…
MoonBun
  • 4,322
  • 3
  • 37
  • 69
0
votes
1 answer

Best approach to game loop timer in typescript with no animation

Suppose I have a react native typescript app, and I have a class Game that has a method startTimer(). When startTimer is called, it need to start running a game loop, which means it needs to call the Game method oneLoop() every (say) 500…
Marc
  • 3,386
  • 8
  • 44
  • 68
0
votes
0 answers

return (goto) to while loop?

I have been working on pygame project based on thenewboston tutorials. It is an older series, I have got some errors while packing game loop into function (it references variables that are not global, if you use direction = "right", gameloop() gonna…
Blandon 93
  • 27
  • 2
0
votes
2 answers

Synchronizing a Game Loop to a desired number of ticks per second with the WIN32 API

I want to write a Game Loop and measure the time it took to render. At the end of the loop I want the Thread to sleep for a certain amount of time to not exhaust the CPU. Currently I want to run the loop 60 times a second. Here is the minimal…
Nicky
  • 121
  • 1
  • 7
0
votes
0 answers

Game loop implementation using Java Swing and Multithreading concerns

I wrote a basic Engine class for a Java 2d game but I'm not sure about multithreading problems though it works good. I decided to run game loop in another thread to avoid the repaint() method of Swing to never being called. /** * Engine class. …
magister
  • 1
  • 1
0
votes
1 answer

How to limit game loop fps?

I'm trying to limit my gameloop fps using SFML but it's not working correctly. if I divide 60/1000 shouldn't the result be the time of each frame to get 60 FPS? I put in 60 but I only get 33 does anyone know where I made a mistake? Here is my…
0
votes
0 answers

HTML Canvas context.clip(new Path2D("...path...")) causing memory leak

I have a simple game-loop that clips the canvas each iteration with a predefined Path2D to create an edge like this: The problem is that over time (~30sec) it starts to slow down in performance linearly. Here is the game-loop code: private…
0
votes
1 answer

Adding a CADisplayLink to Cocos2D

I have Cocos2D in my app and I use it as the game engine for my game. At this point I need to have a game loop fire at the rate the screen refreshes. So this leads me to think that I need to use CADisplayLink. So how would I implement CADisplayLink…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
0
votes
0 answers

how to freeze and unfreeze the game loop?

i have a game loop, i want to be able to make it temporary stop and then make it run again. I TRIED to freeze and unfreeze the game by passing a boolean variable by reference to void functions, which their job is to set the variables value to true…
no_hope
  • 39
  • 5
0
votes
1 answer

Game Loop makes GUI "blinking"

I have a Game Loop: public void startGameThread() { gameLoop(); gameThread = new Thread(this); gameThread.start(); } public void gameLoop() { frame++; if (System.currentTimeMillis() - lastCheck >= 1000) { lastCheck =…
Reyni
  • 11
  • 3