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
0 answers

Is there a more appropriate term than "REPL" to describe the structure of a game loop?

I have recently learned to program Arduino and Processing, which are quite similar to one another. I naturally arrived at the conclusion that the most natural structure to an interactive main loop (which is named loop() in Arduino and draw() in…
0
votes
1 answer

Game loop doesn't work

boolean running = false; Rectangle rect = new Rectangle(10, 10, 80, 80); JButton b = new JButton("Misca-te!");; boolean shouldClearRect = false; String path = new String(); BufferedImage i; int x = 0; double a = x; boolean q = true; public Thread…
HackWolf
  • 23
  • 3
0
votes
1 answer

How to add a JPanel on top of a canvas placing the mouse on the top of a Graphic element?

I am building the test application to improve later. I have a Java Graphic Element drawn on a canvas using a Game Loop (update,render). It is a red ball that changes its color when the mouse is placed on top of it. I am trying to figure out a method…
0
votes
1 answer

What would the logic in the game loop of Lai Games "Stacker" be?

I'm trying to comprehend the logic behind this game: Lai Games - Stacker Arcade Machine In my mind - Each loop will have a master Array. eg. [1,1,1,1,1,1,1] and your player array: eg. [1,1,1,0,0,0,0] and each tick the player will update eg.…
0
votes
0 answers

How can I synchronize a tick() and render() methods in a animation loop?

I am making a animation with java graphics 2D, based on a game loop(tick and render). I want to make a ball walk along a curved line, so I am using a FatteningPathIterator to obtain the points from the Curved line and save them in a ArrayList. Than…
0
votes
2 answers

doubts about implementing different approach of render method in libgdx

Recently, I decided to make a new game and give that chance to libgdx framework. Long time ago, I used to make some games in Slick2D, and I remember that their approach when it comes to update(delta) and draw() object, was different, then now in…
Kapparino
  • 988
  • 11
  • 33
0
votes
2 answers

game Loop performance issue

I am making a bomberman game in Java, the game seems to be slowing the PC overloading the processors and CPU. I have used the loop in another game and it worked fine without causing any performance problem. However I did notice that by simply…
Dev_anon101
  • 107
  • 2
  • 11
0
votes
1 answer

Avoiding unnecessary checks

I have a game that has two modes: timed limited and stock limited (kinda like smash bros). In my game loop, a method called renderGame() is called which updates moving objects display coordinates and then calls repaint(). @Override public…
hjl
  • 15
  • 6
0
votes
3 answers

iPhone game loop hybrid

I had an idea for an app that would require me to implement these little sprites that would require basic physics features like gravity, acceleration, etc... so naturally I looked into a game loop for the iPhone, there were plenty of threads on…
Mark
  • 14,820
  • 17
  • 99
  • 159
0
votes
1 answer

Removing a sprite from Pygame.Group which is declared in a loop

I have found a solution to this problem by moving the sprite off the screen but I was wondering if there was a more ethical way of solving it like removing it from the sprite.group. I have attempted this but because the coin is declared in an if…
Tom Hulme
  • 5
  • 3
0
votes
2 answers

How to navigate back and resume my app without hanging it?

When I run my code below everything works fine. When I want to go back to the previous activity (using the emulator) I get a black screen and then the app shuts down. I also get a black screen when I exit the application and try to resume it. The…
Taegos
  • 343
  • 3
  • 6
  • 15
0
votes
0 answers

Multiple fillStyle in a Game Loop Canvas HTML5

I'm following a HTML5 game tutorial on MDN. In JavaScript whenever my game loop re-calls its-self with requestAnimationFrame(gameLoop); There fillSytle = "someColor"; option of one the functions being called in my game loop changes the color of…
Ahmad
  • 2,629
  • 3
  • 22
  • 27
0
votes
2 answers

Animation synchronisation with FPS

at the moment I am programming a simple 2D Game Engine (Just because i want to do it, i know there are already lots of awesome ones) But this just btw... My actually Problem: I got a normal game loop with methods like update() and draw(). Now I want…
Luftbaum
  • 303
  • 1
  • 13
0
votes
1 answer

Implementing main menu in game loop, Python2 and Pygame

I have a issue with my game at the moment, the game works fine. however when adding my main menu, It doesn't work, it loads it up but when you press play nothing happens (it doesn't go the game it just stays there). I have attached an image of my…
0
votes
1 answer

Unprocessed time in java game loop

I was looking at notch's game loop and i can't understand what is the meaning of unprocessedTime variable. long now = System.nanoTime(); unprocessedTime += now - lastTime; lastTime = now; I would be really grateful if someone could explain me the…
Sabyasachi Bhoi
  • 175
  • 1
  • 6