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

I'm Having Problems with NSTimer in Xcode

im making a simple game on Xcode and i decided to use a nstimer in my .m xcode found 3 problems with my code it says Assigning to 'CGPoint' (aka 'struct CGPoint') from in compatable 'int' twice and it says use of undeclared game loop. Any help is…
Ethan Reid
  • 1
  • 1
  • 5
0
votes
1 answer

Boggle game loop logic

I'm writing a console Boggle game and the gameLoop logic isn't quite what I think it should be. My basic game loop method is: public void gameStart() { timer.schedule(new BoggleTimerTask(1),0); gameActive = true; …
Jeff D
  • 1
  • 3
0
votes
1 answer

How to call UIView animation inside code

I have a rather simple question with regards to UIView animations but it has taken me the whole day trying to solve. I want to implement a UIView animation that will be triggered by an event inside code. Meaning it is not triggered by the user…
0
votes
0 answers

Interpolation in a Fixed Time Step

I've been trying to implement the game loop found in Gafferon Games http://gafferongames.com/game-physics/fix-your-timestep/ but I'm running into an issue regarding the interpolation step. The current algorithm looks like: void draw(float…
Izman
  • 309
  • 3
  • 13
0
votes
2 answers

Fix your timesteps in Java

I've read the article from here. But it seems i can't translate that to Java, and by that I mean this: double t = 0.0; const double dt = 0.01; double currentTime = hires_time_in_seconds(); double accumulator = 0.0; State previous; State…
Romeo
  • 376
  • 1
  • 3
  • 14
0
votes
1 answer

update animation based on time in javascript(independent of frames)

I am implementing a simple animation using javascript in canvas.An image updates its position based on the time elapseddt between each frame. Here is the code var lastTime=0; var speed=100; mySprite = function() { this.pos=[0,0]; } function…
Binu Pandian
  • 163
  • 4
0
votes
1 answer

onDrawFrame, requestRender, and render thread? | OpenGL ES 2.0

i have a problem running my app using an external Thread for game loop in OpenGL ES 2.0. here is my onCreate in my Starting class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGLView =…
Baruch
  • 1,618
  • 5
  • 23
  • 42
0
votes
2 answers

Prototyped Method not being called correctly

Really annoyed at this engine I'm writing, but that's fine, that's what Stack Overflow is for. So I have all my game "Entities" prototyping from an object: function Scene(name, description) { // Initialize the Scene Object /*…
Daniel Gast
  • 181
  • 13
0
votes
1 answer

Object Method not Found after setTimeout

LoCEngine.prototype.runGame = function() { // Initiate our game loop ctx.clearRect(0, 0, 800, 600); this.drawScene(this.curScene); if(this.gameRunning) { window.setTimeout(Engine.runGame, 1000 / this.framerate); …
Daniel Gast
  • 181
  • 13
0
votes
1 answer

How to delete same pointer in different std::vector's?

My game's main loop looks like this: std::vector> states; for(size_t i = 0; i < states.size(); i++) { states[i]->Update(); states[i]->Draw(); } Their is a flaw with this though. I can't modify the vector (delete a…
ProgrammerGuy123
  • 357
  • 1
  • 5
  • 12
0
votes
2 answers

Creating Game Loop on windows phone?

i want to ask if i want to create agame loop for controling motion in my 2D Silverlight game ( sample game like snake) which will run on Windows Phone , what is the best practice to do this ? i found different methods used: 1-…
Ahmed Emad
  • 550
  • 2
  • 7
  • 25
0
votes
1 answer

C# System.InvalidOperationException: Object is currently in use elsewhere

I have already seen questions on the same topic but couldn't figure out how to solve this problem. In my game, I am using two threads one Logic thread and the UI thread. This is the problem I'm having System.InvalidOperationException: Object is…
Sri Harsha Chilakapati
  • 11,744
  • 6
  • 50
  • 91
0
votes
1 answer

Is it possible to set UIAccelerometer delta?

I am writing a game on iOS and I am trying to setup the response movement using the accelerometer. So when I start the game on the iPhone, everything is fine and accelerometer is responding without a problem. But when I stop the game loop (pause…
Setrino
  • 341
  • 4
  • 9
0
votes
2 answers

HTML5/JS - choppy game loop

I've been trying to make a simple game in HTML5/JS. I've managed to get a basic skeleton ready for the state machine and game loop, but even making a simple rectangle move around results in some 'tangible' choppiness. What's more, after leaving it…
Rikonator
  • 1,830
  • 16
  • 27
0
votes
2 answers

Cocos2D: How to send events between different classes

Most of the tutorials that I've read only explain Cocos2D examples in the HelloWorld class, but as I've started to build a simple game I need to know how to send an event to different classes, and for them to respond whenever it happens. I have…
William Robinson
  • 1,038
  • 17
  • 32