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

How to create two way persistence for a game server using Node.js?

Lets say we are building a spaceship game. A few object types would be spaceships, and solar systems. I would like to use Node as the backend. The issue I am having is how to have both these objects existing and interacting with each other in real…
0
votes
1 answer

Show Dialog in Game with canvas when gameover

After finding that starting a new intent might not be the right way to notify user of GameOver, I'm now struggeling with runOnUiThread, Runnable and dialogs.. Question : How and where would I implement a Dialog.show() to notify the user that the…
user1602798
  • 365
  • 3
  • 5
  • 13
0
votes
2 answers

Show and hide object on canvas?

I am developing an Android Games. I have created a canvas on screen. I want to show an object for 2 second on its screen and then it should be disappear. How can I achieve this?
user1602798
  • 365
  • 3
  • 5
  • 13
0
votes
1 answer

Creating GameLoop in Android

I am creating an application related to GameLoop in this application if the user clicks the screen an image is drawn on the screen and it moves on the screen with a random speed and also in the random direction.. In the code there is no errors but…
0
votes
1 answer

Xna firing(updating) objects from an array one at a time

Okay so i have an array of bullet objects that i want to updae everytime the game loop runs. When the update method is called i want one bullet to fire when i click the mouse or press a key, however everytime i press the fire button on the keyboard…
ree
  • 59
  • 10
0
votes
1 answer

XNA Game stack overflow error after 'update' called

Good day everyone, I've been building a cross-platform framework/abstraction layer to target Android, iOS and Windows Phone 7 utilising the Mono and XNA frameworks on the appropriate platforms. I am not utilising ExEn, MonoGame or a similar…
Nathan Runge
  • 303
  • 2
  • 10
0
votes
1 answer

HTML5 canvas game setTimeInterval for multiple objects creating difficulty

I am creating an HTML5 canvas game for the first time. Its a tower defence game, so basically I have an array of enemy objects from class "Enemy" which fly in using a path. Then I also have an array of tower objects from a class "Tower" which kill…
0
votes
1 answer

Game loop in GDI window / doesn't refresh and crashes after a while

This is my current game loop in a normal Window: while(running) { while( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { if( msg.message == WM_QUIT ) { running = false; } TranslateMessage( &msg ); …
Deukalion
  • 2,516
  • 9
  • 32
  • 50
0
votes
1 answer

Update loop and buttons in cocos2d

I have a simple lunar lander game. I compute positions and everything by integration - e.g. each turn I take vectors and combine them and then apply resulting vector to my lander. Here comes the question, I have a button that I want to use for…
Dvole
  • 5,725
  • 10
  • 54
  • 87
0
votes
1 answer

DARK gdk, background covering sprite?

dbLoadImage("media/backdrop.bmp", 2); dbSprite ( 2, 0, 0, 2 ); dbLoadImage("media/greyback.png", 3); dbCreateAnimatedSprite(1, "media/bugsheetsheild.png", 3, 1, 1); 3 is the background that covers the sprite. in the game loop this happens dbSprite(…
user1422770
0
votes
2 answers

2D Game map movement

I have a 2d randomly genrated map for a platformer made of block(squares 40 by 40) stored in an array of 30, i have a push function to move the blocks around push changes the xpos aswell as the position on the array i'm only ever drawing the 5-25…
user23012
  • 219
  • 2
  • 16
0
votes
2 answers

Android Gameloop: End Game and start Activity

I have a problem with my GameLoop in my Android projekt (my first Android projekt): I have an Activity that the GameView (SurfaceView) starts. setContentView(new GameView(this)); The GameView (SurfaceView) starts the GameThread. public void…
-1
votes
1 answer

Is there a performance advantage in using AnimationTimer over just using self made threads?

I recently switched from swing to javaFX and I noticed that everyone is using AnimationTimer to make a game loop. And my question is is there a performance advantage in using AnimationTimer over just using self made threads to run the game loop on ?…
-1
votes
1 answer

Is there any way to permanently display these settings after pressing the button?

I try to display the list of settings after pressing the button, the problem is that I do it in the game loop and it is known that the text will appear and disappear over and over, is there any sensible way to get around it somehow? Thanks in…
JUANOOO
  • 11
  • 3
-1
votes
2 answers

C++ QueryPerformanceCounter and QueryPerformanceFrequency

I have been attempting to create a timer for my game and I heard about QueryPerformanceCounter and QueryPerformanceFrequency. Could someone please explain how these can be used to calculate time/fps/ticks in a game loop?.
I Phantasm I
  • 1,651
  • 5
  • 22
  • 28