The central code loop responsible for handling the running gameplay. At its most basic state, it accepts input, resolves the actions of entities, and renders the scene.

learn more… | top users | synonyms (1)

0
votes
0answers
38 views

update(100) behaves slightly different than 10 times update(10) - is that a problem? [closed]

While looking into some test failures, I've identified an curious issue with my update logic. This: game.update(100); Behaves slightly different from: for (int i = 0; i < 10; i++) ...
16
votes
3answers
3k views

Is there any harm in having the main game loop run uncontrolled?

I was wondering if there is any possible harm when my game loop runs as fast as the system allows? I currently have a loop, that, by measuring passed time in nanoseconds, runs the game logic and ...
5
votes
1answer
115 views

Is there a good alternative to a world state data structure?

How do you avoid one big data structure containing all the current world state ? Let's pretend we're in a real-time strategy game, how would you code a skill that decrease mana of units around it ? ...
0
votes
1answer
58 views

Trying to understand the XNA fixed time step game loop logic

I came across the blog post Understanding GameTime, and after lots of reading on fixed time steps in game loops this is the approach I would like to take. In summary, this is the logic from the post: ...
0
votes
1answer
128 views

Fixing game loop to 60fps makes animation very jittery

ns is 1000000000 / amountOfTicks; long now = System.nanoTime(); delta += (now - lastTime) / ns; lastTime = now; if (delta >= 1) { tick(glad); updates++; ...
2
votes
1answer
84 views

Best practice for organizing the physics of objects?

Apologies because this is a long post and I am inexperienced. I would really appreciate the input from some experienced developers. These are my two goals for this project: To learn the best ...
0
votes
2answers
224 views

How to change from 60FPS to 30FPS while keeping things smooth?

Here is my current game loop: final int ticksPerSecond = 60; final int skipTicks = (1000 / ticksPerSecond); float dt = 1f/ticksPerSecond; while(System.currentTimeMillis() > nextGameTick ...
0
votes
0answers
71 views

Vsync and Gameloops

I was about to publish my app but I tested it on a cheap Android tablet. It's anew tablet, but a cheap / low spec one. The game runs, but is pretty choppy. I'm made a discovery that quite surprised ...
1
vote
2answers
215 views

Where should I put my game loop?

I've seen some tutorials on programming a good game loop, but none mention where (in the game code) I should call it. My guess is I should call it from the main() method. Am I right? Is there another ...
0
votes
2answers
79 views

Updating entities in response to collisions - should this be in the collision-detection class or in the entity-updater class?

In a game I'm working on, there's a class responsible for collision detection. It's method detectCollisions(List<Entity> entities) is called from the main gameloop. The code to update the ...
0
votes
1answer
83 views

How does this game loop actually work?

I read this playfulJS post, about ray-casting: http://www.playfuljs.com/a-first-person-engine-in-265-lines/ It looks really interested, so I decided to look at his javascript. I am no expert in ...
0
votes
3answers
96 views

Separate draw and physics loops

I there a point in updating the physics at a different rate than drawing / taking input? Is it just to exploit parallelism? I've heard that many engines update the physics at 15FPS but render at ...
0
votes
2answers
113 views

How can I efficiently update only the entities that matter in a given frame?

I'm making a RTS, which can potentially have lots of units in one map (think Age of Empires). I'm looking for a way to update my units. I want to avoid calling a virtual Update() method every frame ...
0
votes
0answers
179 views

Limiting game loop to exactly 60 tics per second (Android / Java)

So I'm having terrible problems with stuttering sprites. My rendering and logic takes less than a game tic (16.6667ms) However, although my game loop runs most of the time at 60 ticks per second, it ...
2
votes
2answers
256 views

Frameskipping in Android gameloop causing choppy sprites (Open GL ES 2.0)

I have written a simple 2d platform game for Android and am wondering how one deals with frame-skipping? Are there any alternatives? Let me explain further. So, my game loop allows for the ...
4
votes
2answers
1k views

Why does my turn-based game loop allow the enemy to act repeatedly?

I'm trying to create a turn-based game in pyGame but hit a wall when trying to properly handle the main game loop. So I have something like this: def loop(self): while self.stategame==1: ...
0
votes
0answers
114 views

Limiting Rendering in my game loop (Not Game Updates)

My Gameloop (code below), limits the game updates to 60 ticks per second. However, it renders as fast as the device on which it is being run can handle. I'm using a fixed time step in my game and I ...
2
votes
1answer
135 views

Running state in Behavior Trees

What happens, in a behavior tree, when a priority node chooses another branch over a running branch? Small example: Priority 1: Fight Sequence: -Enemy near? -Fight! Priority 2: ...
1
vote
0answers
123 views

Abstracting Game Logic from Game Engine [closed]

I've seen that the Quake 3 Engines uses QVMs and DLLs for the gamelogic. Unity uses some kind of Component-Entity system. My question is basicly: What's a good way to keep the engine seperated from ...
1
vote
0answers
96 views

What's the best way to set up an OpenGL draw loop in windows?

On mac os x, there's a way to pass the system a function pointer that is triggered at an ideal time to start your drawing code. These are the CVDisplayLink tools. I'd like to understand how to do ...
0
votes
1answer
110 views

Game Taking too long during render cycles [closed]

Firstly, I'm not asking anyone to read my code. It is only posted as a reference just in case you want to. I am asking for general tips on how to get my game running at higher FPS on android, for ...
4
votes
3answers
249 views

Make openGL program only update every 1/60 seconds

I'm learning C++ and openGL and have this program as a result from tutorials and playing around. The problem is that the main loop is running at "full speed", making the program unnecessarily cpu ...
-1
votes
2answers
138 views

What happens when a character attacked in fighting game?

I went through many websites explaining fighting game systems, frames, hitboxes, but i couldn' find the answer so i ask here. Basically fighting game hitbox system works like this : 1.Player A ...
3
votes
1answer
119 views

Game loop in Javascript

I've been into javascript game programming with html5 and canvas lately. So far I've only been able to implement a game loop with setInterval, but I'm aware this means using fixed timestep. I've ...
1
vote
3answers
343 views

How can I implement a main menu?

I have been following the tutorials at http://lazyfoo.net/tutorials/SDL/index.php and although they are all very well written and I have learned more than I would have on my own, I am not sure how to ...
1
vote
1answer
215 views

Should game logic update per second or per frame?

I'm trying to wrap my head around how and when to update an entities position. My game loop updates logic at 25 FPS and renders at 50-60 (Depending on the computer hardware). So lets say I'm moving ...
3
votes
1answer
140 views

Pro's/Con's of separating game logic and render threads

Originally, I have thought that it is good practice to separate my game logic (updating) from my rendering thread. In this threading model, the rendering thread has no limitation on frame rate and ...
7
votes
3answers
2k views

Is a separate thread for game loop compulsory for simple games?

I am new to game development. In order to learn I am recreating this game on android platform. You can observe the game-play video at the above link. It is a simple game. I have read a lot of ...
1
vote
1answer
699 views

Game Update in Libgdx

In libgdx, the game loop is the render() method. But why is that, and is there a way where I can make an update() method that is called 60 times a second? As in the update() method, I would add the ...
1
vote
3answers
100 views

Why is my FPS computation yielding higher numbers than I expect?

I have following code: void Game::execute() { isExit = false; init(); double dt = 1.0 / 60.0; boost::timer timer; double accumulator = 0.0; boost::timer fps_timer; int ...
0
votes
3answers
248 views

Delta times and frame lag in the game loop

Let's say we have a standard gameloop like this, in pseudocode: while (true) { dt = GetDeltaTime(); Update(dt); Render(); } Here Update(dt) either uses a true variable timestep, or it ...
5
votes
2answers
722 views

Why is my gameloop logic not being restricted to 60 per second?

Here is my gameloop (taken from http://www.koonsolo.com/news/dewitters-gameloop/) which is supposed to limit the game (logic) updates to 60 per seconds and render as fast as the device allows: long ...
0
votes
3answers
263 views

How can I avoid a busy-wait in this game loop implementation?

I've been developing a small framework for OpenGL and WinApi for some research purposes. My biggest problem right now is the game loop. Simplified I did something like this: Main thread: HANDLE ...
1
vote
0answers
148 views

iOS OpenGLES - Multithread Game loop - Render and Update

I am trying to implementing multi-threaded game loop in iOS. (Actaully, two thread - Render and Update) This is my structure. Update Loop Has logic and at the end of loop, save update state. ...
3
votes
2answers
270 views

HTML5 game fps render lag

I am currently creating a flappyBird-like HTML5 game using Proccessing.js You can see current work here: http://files.tips4design.com/flappySlothRelease/ The problem is that even though the FPS is ...
2
votes
1answer
201 views

Why game loop should be running on a separate thread?

I am struggling to fully understand the responsiveness argument suggesting to run the game loop on a separate thread other than main thread. When OS sends a user event (touch, mouse move, etc.) it ...
4
votes
1answer
87 views

Dealing with interpolation and object creation/destruction

I've implemented a game loop similar to that in Glenn Fiedler's Fix Your Timestep! article. I have an update step running at 50Hz and a render step running at 60Hz (monitor refresh rate). To keep ...
0
votes
1answer
133 views

moving first person camera with the mouse on right click

I am new to game development and I am trying to get the game input working. I have successfully got all the movement keys for walking/running/looking around working; however, I am having a terrible ...
1
vote
1answer
209 views

Game Loop: Best way to limit the fps? [duplicate]

My game-loop looks like this: public void run() { init(); final double amountOfTicks = 60.0; double ns = 1000000000.0 / amountOfTicks; long ...
2
votes
1answer
209 views

does order of updates and renders matter?

I know in a game loop there needs to be an order like physics should update before rendering. So, I have created two separate functions: update and render and the game loops like below: ...
2
votes
2answers
190 views

Physics engine deltaTime and force acceleration

I am working on a physics engine that uses basic Euler integration to compute forces. So, here is the thing: function applyForce (rigidbody, force) { rigidbody.forces.add(force); } function ...
0
votes
0answers
145 views

Server Character Movement calculation

I am creating the movement function for an 3D MMO game server. It seems that I cant no get the position calculation to match the client and was wondering the best way to do this. Let me explain. The ...
1
vote
1answer
199 views

Implement an upper FPS limit in the gameloop

I implemented my game-loop as described in deWiTTER's article, using the last approach with an unlimited FPS and a constant game-speed. My problem is, that the unlimited FPS cranks up my CPU usage to ...
1
vote
2answers
137 views

Should the game update loop compensate for slowness

I am building a game engine and considering the design for the core game loop that will drive the game. In the most basic form, the implementation looks similar to this (in pseudo-code): while ...
13
votes
2answers
3k views

What is the standard C# / Windows Forms game loop?

When writing a game in C# that uses plain-old Windows Forms and some graphics API wrapper like SlimDX or OpenTK, how should the main game loop be structured? A canonical Windows Forms application has ...
1
vote
1answer
205 views

Python game loop approach?

I intend to write a game in Python and, later, if needed, offload any performance-critical sections of code to C++. I want to use Python basically because I am really familiar with the language and I ...
-1
votes
1answer
142 views

why are there draw rate and update rate in fixed time step game loop?

http://www.gameprogblog.com/generic-game-loop/ Java boolean onLoop( Game game, GameState state, GameInput input, Graphics2D gr ) { long nanosElapsed = state.tick(); updateTime += nanosElapsed; ...
1
vote
2answers
135 views

LUA - Keeping track of game state for a digital card trading game

I am building a card game. Let's say it's similar to Magic the Gathering, Hearthstone, etc. The problem I am trying to figure out is how to architect "auras" and how much damage each card takes. ...
23
votes
4answers
2k views

What is the point of “delta” in this code? Does it reflect a standard thing in game dev?

I know very little about game programming but would like to learn more. I am trying to understand the code for this game. I am trying to understand why the code is passing a "delta" to ...
0
votes
2answers
289 views

Cocos2d: Moving background on update: offsett issue

working with Objective C, iOS and Cocos2d I am developing a vertical scrolling shooter game for iPhone (retina display models with 640 width x 960 height pixel resolution). My basic algorithm works ...