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
1answer
36 views

Snake user input

So I'm basically doing a snake game in Console Application. I'm kind of new to programming and I'm not sure how to do the game loop. My code looks like this: while (true) { System.Threading.Tasks....
0
votes
1answer
75 views

Turn Based Game- Determining turns

I am developing a Checkers game and need to implement players' turn, particularly after "Capturing". Changing turns after single steps work properly but not correctly after capturing. In the drag ...
0
votes
0answers
62 views

Efficient use of database in game loop

I'm trying to write a simple browser based style game (I say browser based style because I'm running it all locally). The game is a real time strategy in which player control towns and armies and try ...
0
votes
1answer
111 views

Can I always assume that fixed time step in Unity is reliable?

I was thinking about games on low end machines or phones where the CPU would be limited. If I were to move all of my game logic into FixedUpdate() can I assume that it will always be called with the ...
64
votes
5answers
6k views

What is the point of update independent rendering in a game loop?

There are dozens of articles, books and discussions out there on game loops. However, I pretty often come across something like this: while(running) { processInput(); while(isTimeForUpdate) ...
0
votes
0answers
44 views

Unpleasant periodic stutter in game loop

The game is running smoothly otherwise. However in certain periods the game stutters. So it goes from smooth...stutter...smooth and so on. The intervall between these is like 2-3 seconds on average (...
0
votes
0answers
43 views

A central game controller responding to events vs global event system

Say you have combat mechanics and your projectile object fires an EnemyHit game event. You'd like to hook up a UI element indicating damage numbers. I've got two options: Receive that event in my ...
0
votes
2answers
85 views

Implementing “Fix Your Time Step”

So far I have this implementation of "FYTS". However I am facing several problems. final int TICKS_PER_S = 60; double accumulator = 0.0; //The timestep final double dt = 1/(double)...
0
votes
0answers
58 views

How to slow down snake without making it collide with itself?

I just finished writing my first game ever, snake, in lua using Love2D. The entire source is here: https://github.com/AriaFallah/snake. Here is the problem: My snake is made of 10px by 10px segments, ...
2
votes
1answer
54 views

How do I draw a high-performanced scatter plot

I am new to DirectX and currently I'm trying to use it for data visualization, to be specific, a 3D scatter plot. There are very limited resources on the internet, and I have read part of Frank D Luna'...
1
vote
0answers
31 views

Prevent rendering queue from overflowing when using Vsync

My game loop currently looks something like this: while (!quit) { takeInput(); // Input is sampled however fast loop can run time_now = get_time() time_passed += (time_now - time_prev); ...
0
votes
0answers
28 views

Keeping track of space objects: enemies, projectiles, players

I have a Vector called spaceObjects of type SpaceObject that contains all types of SpaceObjects: Heros, Projectiles, and Enemies. I've added all these to this one Vector because I'm passing it all ...
0
votes
1answer
69 views

C++ Independent Objects?

before I started C++ I digged around in ActionScript3 for a while. The first thing I've noticed is that you apparently have to call all your objects/game-characters individually and tell them to ...
0
votes
1answer
38 views

Reference sf::RenderWindow from another source file in SFML

In SFML, How would you be able to reference a window in your main.cpp file to another source file? I want to be able to reference the window made in main.cpp from player.cpp, so I can keep everything ...
0
votes
1answer
60 views

Game loop entering tick more often than expected, and over time delta time seems to decrease.

I am writing a simple ascii game in java. My main loop has a tickrate set to once every 10 seconds, which calls a KeyListener attacked to the JTextArea that the game is displayed in. The KeyListener ...
0
votes
1answer
88 views

Windows Forms game loop

There is a very good game loop in the link which is tailored for windows forms. I need it in c++/cli so I converted the code as below. Here is my main loop. using namespace System; using namespace ...
0
votes
1answer
43 views

How to handle keyup events in game loop?

I'm writing a simple game in JavaScript, which already handles basic keyboard input like so: var input = {}; while (!done) { handleInput(input); update(); render(); } document.onkeydown =...
1
vote
2answers
179 views

Game Loop getting 58-62 FPS. Why not exactly 60FPS? (SDL/C++/OSX)

Here's my game loop: uint64 target_fps = 60; uint64 ticks_per_s = SDL_GetPerformanceFrequency(); uint64 target_ticks_per_f = ticks_per_s/target_fps - (ticks_per_s/1000); //aim for (target - ...
1
vote
1answer
107 views

Smoothness & performance issues of new game

I've written the basics of a new game which just includes a game loop that can update and render basic game objects so far. I want to ensure that what I've written so far is as good as it can be and ...
0
votes
3answers
78 views

Long delta time and collision detection

When player's computer stutters/he tabs out of game stopping requestAnimationFrame calls, movement system tied to the delta time creates a huge leap, bypassing probable collisions. This allows player ...
3
votes
2answers
76 views

Unity Animation Tracking

Background I've recently reached a bottle neck in my game's code that forced me to completely decouple the logic/networking from the graphics. Thanks to the nature of my board game, I was able to ...
1
vote
2answers
49 views

Updating bots/AI behavior after a fixed elapsed timestamp in game loop?

I am developing a HTML5 game in javascript. Now I have created a few bots and they should be able to change their orientation after a few seconds/a fixed timestamp in the game loop. Suppose my game ...
0
votes
2answers
117 views

How to kill a fired bullet sprite after certain amount of time in Phaser?

The bullet should be killed after it was shot from the player, and after a certain amount of time. function create() { bullets = game.add.group(); bullets.enableBody = true; bullets....
8
votes
2answers
136 views

Fixed timestep with interpolation & rounding draw positions: jerky animation when the character is not moving

I've implemented a deterministic, fixed timestep system from here: http://gafferongames.com/game-physics/fix-your-timestep/ Everything works fine, output is the same with each step but there's one ...
0
votes
0answers
45 views

Setting up game loop wait time and FPS

I have been able to set up the game loop method/function, but many objects do their stuff in separate threads. The reason for that is not ensure, that the program is not going to stop working, despite ...
1
vote
2answers
142 views

Game loop with fixed timestep gives strange result

So I've read the famous article at http://www.koonsolo.com/news/dewitters-gameloop/comment-page-2/#comments which describes different methods of implementing a game loop. I've tried to implement the ...
3
votes
0answers
166 views

Tick frame: update order problems

Sorry, it's a bit long story but I hope you can help me. First of all: I have an entity class called SceneObject. The SceneObject has components (eg. RenderableMesh, Camera) and transformation data (...
0
votes
1answer
70 views

Creating 3D gravity in zero-G tied to mass in unity with c#

As a total beginner, I've been working on a patch-job script for a gravity mechanic in an open space sim, I want to derive all my objects from this "Block ALPHA" object and its' set of variable ...
0
votes
1answer
36 views

Loop in coroutine stops after going halfway

I have a very weird problem with a particular loop in a coroutine: public IEnumerator DestroyCubesGameOver() { var startingCubeHolder = GameObject.FindWithTag("StartingCubeHolder"); ...
0
votes
1answer
53 views

Is Update(GameTime) called before it's finished?

Code at the beginning of Update(GameTime) is being called over and over again, and code at the end of Update(GameTime) is only being called after a delay. Is Update(GameTime) called again before it's ...
0
votes
1answer
165 views

CPU and RAM usage in OpenGL too high in Swift

My game is set up so the the display controls the game loop, usual in Cocoa. The callback function calls run() which is this. The thing is, the thread running the callback is using 63% CPU and the RAM ...
0
votes
1answer
141 views

Why is my deltaTime in my GameLoop 0?

I have a question about my code. I wrote a basic GameLoop for an Android Game and while testing it I realized the deltaTime is always 0. The code looks like this: @Override public void ...
2
votes
2answers
236 views

Game Loop design that is speed hack proof

I'm not sure if this is possible, but it's worth a shot asking. How does one design a game loop in such a way that hooking and enabling a speed hack app to the game(dx11) doesn't matter? I found this ...
3
votes
1answer
99 views

Correct order of entity updates and collision detection

I'm trying to simulate a number of units walking in a single file. My update loop looks like this: for each unit: n = compute next position if n is empty then move to n If I start the loop ...
0
votes
0answers
32 views

Do I restart the service?

I have a long running service in my game, that consists of two threads. //MY SERVICE: if(userEnabledProcessOne) //Shared preference value that I'm getting from the settings of my app based on a ...
0
votes
1answer
424 views

Game loop architecture using WPF(MVVM) and C#

Could i get some suggestions on how to implement a game loop whilst using WPF(MVVM) and C#, I am a professional developer and understand the technology well. The game loop usually contains a Init(), ...
1
vote
1answer
64 views

Repaint() in gameloop does'nt work [closed]

Recently I'm working on a PAC-MAN clone. I created 3 classes: StartingClass which extends Jframe and uses KeyListener Board which extends Jpanel Sparx which is responsible for changing the ...
0
votes
0answers
125 views

Custom game loop entirely in the Update method

I am attempting to implement a custom game loop in XNA/Monogame. I know that one can re-implement the Game class using WinForms (with the caveat of having to also redo the content manager, etc.). I ...
0
votes
1answer
130 views

Organizing Setup(), Update() and Draw() function in a game engine

I'm creating my first game engine and I want help with organizing the Setup(), Update() and Draw() functions in the correct way. Here is how my main() function looks like /* BEGIN main() Function */ ...
0
votes
1answer
120 views

How to Implement a Timer for my Prefab for Roll-a-Ball Game (C# in Unity)

I am trying to create a public float timer that senses when the particular prefab has not been there for a certain amount of time. Then, it will replace that particular object. The goal is to ...
6
votes
1answer
226 views

How to execute game logic every 100ms but render as fast as possible?

I have created a simple snake clone and would like to execute game logic every 100ms while rendering as fast as possible. How can I achieve this when the program might run with very different frame ...
0
votes
1answer
51 views

Competing keyboard events

When I was looking on how to handle key inputs in a game loop I came across the following pattern: All native key events (up or down) get queued in an event queue that is later processed. The outcome ...
3
votes
1answer
233 views

How can I separate processing input and update?

I know that game loop is broken up into three distinct phases: processing inputs, update, and render, but I just can't see how I can make processing input and update independent of each other. Let's ...
2
votes
1answer
64 views

Game loops using Hard realtime systems vs Soft realtime systems

I have read the article here about realtime systems and am looking for examples specific to game loops. Am I correct in saying: Hard realtime systems will lag and slow down gameplay causing slow ...
0
votes
1answer
128 views

Game Loop and Animation states/frames

I just wanna be straighforward. I read a dozen of articles talking about game loop, components, modules, structures, time control, etc... But, in the end I'm still somewhat confused of how animation ...
6
votes
1answer
430 views

In JavaScript, should I write a game loop for a turn-based game?

I am using javascript and HTML5 canvas for turn-based games (e.g., checkers, mastermind, minesweeper). Should I write a fixed-timestep game loop? What are the alternatives?
-2
votes
1answer
132 views

Why is my delta time constantly under 1 millisecond?

I have a game loop that looks like this: while (Sync()) { DoStuff(); } The sync function computes my delta time like this: bool Sync() { EndTime = GetTime(); DeltaTime = (EndTime - ...
0
votes
1answer
163 views

Most efficient way for nested loop to not repeat a value of parent loop in pair-wise structure (C# or Javascript) [closed]

It's hard to choose the correct title for this question, so let's see if I am able to better convey here what I am in search for. If the title is too far away, suggestions are welcome and I can edit ...
0
votes
0answers
36 views

Controlling when a Java game repaints

I've been learning how to program game loops lately and the issue I'm running into at the moment is figuring out how to repaint my window only when I tell it to. I suspect that my issue is not fully ...
1
vote
1answer
87 views

How should I define interaction modes in a strategic game?

I am creating a typical strategic game that gamer can select, deploy and move the game characters (Human mostly) and move or create buildings on its isometric map. These all are going to be done by ...