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
52 views

Perfect game loop [closed]

I've been working on development for an android game, and this is the game loop I have so far: @Override public void onDrawFrame(GL10 unused) { // Use this structure to set constant dt on a ...
0
votes
1answer
103 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++; ...
0
votes
1answer
45 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: ...
2
votes
1answer
75 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
57 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
3answers
80 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
252 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 ...
0
votes
2answers
190 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
55 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 ...
0
votes
3answers
211 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 ...
1
vote
2answers
208 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
1answer
76 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
2answers
101 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
126 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
242 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
105 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 ...
1
vote
0answers
120 views

Abstracting Game Logic from Game Engine

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 ...
2
votes
1answer
111 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
2answers
295 views

Multiple pipelined game loops

I am considering using the following game engine design pattern, but I am unsure if it's a good idea or not: Each major task (drawing, physics, logic, networking, disk I/O) will have its own ...
1
vote
0answers
84 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
107 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
227 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
131 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
116 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
285 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 ...
80
votes
3answers
25k views

Tips for writing the main game loop? [closed]

Can anyone recommend some good tips, articles, sites, etc. for writing the main game loop? What are some things that you should do in the game loop, and what are some things that you shouldn't do in ...
13
votes
2answers
2k 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
198 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
130 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
1k 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
528 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 ...
2
votes
2answers
614 views

Why do my update and draw loops throw a concurrent access exception?

I've taken up the challenge of creating a basic 2D side-scrolling monster truck game for my little brother. It seems easy enough in theory, but jumping into Java out of XNA feels strange. My game ...
5
votes
2answers
718 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 ...
1
vote
3answers
99 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
226 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 ...
3
votes
2answers
230 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 ...
1
vote
0answers
135 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. ...
2
votes
1answer
193 views

How to implement a multi-platform Java 2D game engine's graphics?

I'm not sure whether this question should be posted here. I'm trying to make a basic generic game engine in Java. Here's what I have so far. public abstract class Device { public abstract void ...
0
votes
8answers
851 views

Games development with a game loop that's abstracted away [closed]

Most game development happens with a main game loop. Are there any good articles/blog posts/discussions about games without a game loop? I imagine they'd mostly be web games, but I'd be interested ...
2
votes
1answer
198 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 ...
5
votes
2answers
465 views

Physics in my game confused after restructuring the Game loop

I'm on my way with making a game in Java. Now I have some trouble with an interpolation based game loop in my calculations. Before I used that system the calculation of a falling object was like ...
4
votes
1answer
86 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
115 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
189 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
3answers
1k views

Speed, delta time and movement

player.vx = scroll_speed * dt /* Update positions */ player.x += player.vx player.y += player.vy I have a delta time in miliseconds, and I was wondering how I can use it properly. I tried the ...
2
votes
1answer
202 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
176 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
142 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
161 views

Problem with Scanner class in Java [closed]

I'm pretty new here (as though to a game development). So here's my question. I'm trying to organize a really simple game cycle in my public static main() as follows: Scanner sc = new ...