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

Exception in thread "GameThread" javax.media.j3d.CapabilityNotSetException: Group: no capability to set transform

I am using Java3D (A java extension by oracle) to make 3d stuff (obviously) and I am trying to spin a 3D object but I keep on getting this error: Exception in thread "GameThread" javax.media.j3d.CapabilityNotSetException: Group: no capability to set…
Hoax
  • 76
  • 8
0
votes
0 answers

How to improve JS Game Loop?

So I've been working on a small game project in js for a few months now, and I've realized that the way I've structured my game loop doesn't allow for the game to jump ahead a frame if there is lag. This means that if the game uses up the cpu, it…
Dr. Slate
  • 31
  • 4
0
votes
1 answer

Stuttering some times using Gaffer's fixed timestamp on Android using OpenGLES 2.0

I am having some micro stutterings in my game loop. I implemented correctly (I think) the fixed timestamp tecnique from https://gafferongames.com/post/fix_your_timestep/ I think when the tecnique is implemented correctly, the sprites movements are…
0
votes
3 answers

JavaFX How to Handle Input With Very High Framerate?

I'm on Ubuntu 20.04 using OpenJavaFX. I want to have the user press the escape key to toggle the display of a menu. Due to the very high frame rate, I'm struggling to achieve this. The simple program: class AutoScalingCanvas extends Region { …
0
votes
2 answers

Pygame not exiting even after receiving keypress

So I'm trying to exit the pygame using a function but its not working. It's definitely entering the function block but for some reason is not quitting after the keypress. import pygame from pygame import mixer from random import * from math import…
Avyay Nair
  • 23
  • 4
0
votes
1 answer

Start() Method not running- Java

Im am fairly new to Java as well as at making a game loop and am trying to create space invaders. However, when I execute the code the start() method does not run. why is this not happening? Is there other things I could change too to make it run…
0
votes
1 answer

Tic tac toe game loop stops when it is a draw - Java

According to the requirements from my learning platform works fine apart from when the input command is "start easy easy" and the result is draw program doesn't stop and nothing happens after that and I have to force end the program. In all other…
J Akhtar
  • 669
  • 1
  • 7
  • 25
0
votes
1 answer

How to use addEventListener in a game loop

I'm relatively new to Javascript, so please bear with me if this is a rather trivial problem. I'm trying to make a game where I can control a player with the arrow keys. A simplified version of the code (which doesn't work) looks like the…
Henry
  • 103
  • 2
0
votes
1 answer

Physics update lag

I ran into a problem, where doing everything on a single thread may lead to some lags. The problem is, when I start to create loads of new objects (like 300 per second), my physics rate drops. I sort all rendering objects each frame, so I would know…
Mahrkeenerh
  • 1,104
  • 1
  • 9
  • 25
0
votes
1 answer

Android Java App cashes when minimizing/tabing out

Every time I minimize my App it instantly crashes. The Error is the following: Also stackoverflow demands i add more than just code so here is some text. Also stackoverflow demands i add more than just code so here is some text. Also stackoverflow…
0
votes
1 answer

Approach for Android game with timers and touch event (move) handling

I'm doing a game with game loop and active rendering (using SurfaceView and SurfaceHolder.Callback). I'm wondering how to make that work together with timed events and touch event management. The timed events are like each xx ms something happens,…
Peter
  • 1
  • 1
0
votes
1 answer

Stop game loop on conditional with React

I am unable to stop the loop after a conditional. I am able to stop the interval after a button click but unable to stop it after a conditional such as loop increments. This simple example tries to stop the interval loop after 5 loops. Any solutions…
Pierre
  • 460
  • 4
  • 11
0
votes
1 answer

Cardgame, loop returns None

I can't seem to get this working. I've got a loop for a simple card game of higher or lower, and what I'd like to do, is return the card or any values of the card, and the points so that I can pickle them for storage and play this game over and…
0
votes
2 answers

Why is my Java game crashing when I add a game loop?

I've recently started to try to learn java. I thought maybe making small games would be the best way to get familiar with java, so that's what I'm doing. So, I started my first game, and it's looking good. It's just a grid with a player in the…
alexholstv
  • 146
  • 1
  • 10
0
votes
0 answers

Why am I getting Infinity FPS in Javascript & where is the script getting this string from?

Trying to Create a Codepen example with Html, Css And Javascript, I've just Added a FPS counter but its not outputting an Actual FPS, Instead its printing Infinity to the span That I have used as a container. No where in my Js is Infinity assigned,…
Ryan Stone
  • 345
  • 4
  • 19