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

A-Frame Game Loop Basics: How can I seperate logic from rendering?

I'm dabbling with A-Frame and my Quest 2 headset, trying to make a simple VR game. I'm having trouble wrapping my head around separating logic from rendering and implementing a proper game loop. I found this…
0
votes
3 answers

Game Loop and GDI over .NET CF

Hi i want to write a game with a main game form and lot of other normal forms. What is the best way to manage update-paint cycle in that case? Should the game form paint loop only should be overriden? or should i do an application.do events() in the…
Azlam
  • 2,052
  • 3
  • 24
  • 28
0
votes
0 answers

how can I make my delta gameloop stop lagging in Java?

I'm creating a flappy bird kind of game. The fist step was to setup a Frame, panel in the main class and a Player class that extends JLabel. In this class, I've created a fall() method that sets the players y location to + 7. Then I created a…
AnsG
  • 5
  • 5
0
votes
1 answer

HTML 5 efficient drawing on canvas for game

I am attempting to develop a game with canvas element. Right now, I am drawing tiles (colored squares) as the background, and the hero controlled by arrow keys based off of this demo:…
Raptrex
  • 3,915
  • 10
  • 49
  • 61
0
votes
0 answers

Exporting a directory from whatsapp in gameloop

I have a windows 10 on my computer, recently I have installed gameloop on it to be able to use whatsapp in windows. I want to export a folder sent by a friend from whatsapp. how can I do that?
developer
  • 39
  • 1
  • 6
0
votes
1 answer

game loop delta time is not working with specified fps

Somehow deltaTime is usually 0.01667s (60fps) even though targetFrameRate is 30 (0.03333s), and yes targetFrameRate is working(adding delay). This makes movement code not work as intended with the specified fps when it is greater than or less than…
0
votes
3 answers

Creating a game loop (sleep time help)

I've been using this tutorial to create a game loop. In the section marked "FPS dependent on Constant Game Speed" there is some example code that includes a Sleep command I googled the equivalent in java and found it is Thread.sleep(); but it…
Jack
  • 2,625
  • 5
  • 33
  • 56
0
votes
1 answer

Jquery Game-loop Selection Drop-down

Please help, how would you make a timer that runs some code for a time specifed by the user selecting an option from a dropdown menu ? Jquery please. PS: I tried to attach my code but I'm getting errors (here on the stacks) Please help, any ideas…
0
votes
3 answers

Javascript simple game loop - how to interval?

I have a simple game loop that goes like this: function update(progress){ //do something each second //do something else twice per second //do something else each two seconds } function draw() { //code here... } function…
SKAE
  • 83
  • 1
  • 10
0
votes
1 answer

PaintComponent doesn't draw BufferedImage grid on JPanel

I created a 600 x 600 grid for a TicTacToe game, but every time I try to get the image(Using the getImg() method), it shows a white screen. The JPanel's background is darkGray, it neither draws the grid, nor does it show the JPanel background. This…
0
votes
0 answers

Java - Implement Draw/Doodle as mouse is moved in a Game Loop

Hello I would like to implement a feature in my program that allows the user to draw freely on a certain portion of the canvas so long as they have their mouse clicked, and releasing to stop. The problem is that I want to run this in a loop, which I…
akaBryan
  • 92
  • 7
0
votes
1 answer

Pygame 'DIsplay mode not set'?

I (tried) to create a game menu and placed my GameLoop in the Class = Menü. When I try to start the code it highlights the line pygame.display.update() and tells me that: Display mode not set. Class Menü(Highscore): def __init__(self): …
Shpend
  • 5
  • 2
0
votes
1 answer

Output doesnt show the change i am trying to make in a globally declaread array

I am trying to make a game of tic tac toe. I have declared this global array of character type. #include static char game[3][3]={{' ',' ',' '},{' ',' ',' '},{' ',' ',' '}}; Then I am trying to change the values of the array elements…
SaphiMoon
  • 19
  • 5
0
votes
0 answers

IntelliJ: When repeatedly running program inputs are sometimes recognized and often ignored

So I have been following a 2D game development tutorial for Java and I am using IntelliJ with java 1.8.0_201 and the program seems to ignore my inputs randomly when running the program. Like for example, I can run it once and the inputs will work…
Matthew
  • 41
  • 2
0
votes
1 answer

Java Game Loop With editable frame cap

I'm trying to create a game loop in java which has a frame cap which can be set while the game is running. The problem im having is I have a render() function and a update() function. Just setting frame cap for both render() and update() means that…
user13351174