Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [game-loop]

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.

0
votes
1answer
17 views

Canvas Infinite Map: How to have reappearing objects at static X,Y even when looping

I made a html canvas example of an infinite scrolling map with objects in static places. As you can see in the Fiddle below, when you move left with the Arrow Keys, you can see that the map does not ...
1
vote
1answer
28 views

NodeJS client gameloop running slightly faster than server gameloop

So I'm working on a real time multiplayer game in NodeJs (Client and Server). Both loops handle the same "physics" (movement at a constant rate) and both are running at 40hz or 40 times per second. I ...
1
vote
1answer
42 views

SDL2 mouse motion event keeps occuring

The code I'm using is like so: ...
0
votes
1answer
55 views

Use vsync event instead of a 16ms timer?

I found that in game development, most people set a timer that gets triggered every 16ms to do the rendering. As an Android programmer, I'm familiar with the Choreographer. You set a callback that ...
0
votes
1answer
52 views

Time loop/ticking architecture

Say I build a snooker game, where balls need to jitter around. Balls belong to a class (ball class), where all the ball functions are defined. In the animation, time evolves by a clock ticking ...
0
votes
0answers
25 views

How to reconcile idle ticks for multi-player client side prediction?

I am building a 3D 3rd person real-time action MMO. I am in the process of instrumenting client-side prediction and server reconciliation. I have authoritative game state snapshots being sent ...
0
votes
2answers
108 views

While loop running in thread, but not doing anything [C++]

I am trying to multi-thread my game so that one thread updates and renders the player, while the other listens for inputs. I used a while loop to keep my detached thread running in the background, ...
1
vote
1answer
117 views

My Java Game's movement looks awfull. Maybe Problem with Thread.sleep

I have a big problem with my Java games. In every game I make the movement of the player and objects just looks awfull. The framerate is 60 fps without any problems. But the movement looks extremly ...
1
vote
1answer
104 views

MonoGame tick cannot go lower than 16ms

I'm trying to build play with MonoGame and I'm trying basing this regarding the GameTime steps. In my main Game class that is being run in the main entrypoint of my project, I'm doing something like ...
0
votes
1answer
38 views

How can I speed up the shapes drawing on high-density devices?

I have a game that should draw many shapes on the canvas and in every frame these shapes position will change, the game is running smooth but after adding more shapes some jerk arise and it drops some ...
2
votes
1answer
503 views

Render Stutter - OpenGL or loop timing?

For some time now i have no been able to pinpoint the nature of the rendering stutter shown above(by not clearing the screen, not using SwapBuffers and drawing only to the front buffer). See the big ...
0
votes
0answers
95 views

Java Game is slowing down

Every time I start the game it works fine but after a second everything starts to slow down almost exponentially and i am currently not able to find my mistake. Here is the main code: ...
0
votes
0answers
21 views

I want to generate obj at random places which can move in random speed in X axis in Unity

I am working on something. In this project I want to generate a object at a random position which can go left to right continuously. So far I have got this. This is inside start of a class that ...
0
votes
0answers
63 views

How is performance when having game loop in server side?

I'm creating a game server with .netcore. I've implemented lightweight game object system, And work well so far. It have no game loop, no graphic. Just GameObject and Components kind of things. ...
-1
votes
1answer
93 views

Use two Gameloops instead of one

I have been thinking about this a lot and don't know if i'm thinking incorrectly. Most games have one game loop that can be split into three functions. A basic game loop would look something like ...
1
vote
0answers
70 views

Making games on Structure programming language c or c++ [closed]

I am learning structured programming language C. I know about data type, control statements, loops, arrays, strings, functions, pointers, structures and STL. My question is, if I want to make game ...
2
votes
2answers
127 views

Time based events separate from the game loop

How can set up time elapsed based events separate from the game loop? I want the character to heal over real time rather than per cycle of the game loop. How might i do that?
0
votes
1answer
133 views

How to sleep for the desired duration between game loop iterations?

My game loop below doesn't sleep as log as it should. The delta value always ends up less than 1, when it's supposed to be 16.6666 or close to 16.6666 ...
3
votes
1answer
497 views

Java Game Loop Efficiency

I'm quite new to java. I was watching 2 video tutorials on how to make java game and read a couple articles about game loop. However, I'm still confused about how game loop actually works. The ...
1
vote
1answer
101 views

Game object appears to accelerate too slowly

thank you for checking out my issue! I am trying to develop a game in java, but I have run into a problem. I would like to keep the physics as realistic as possible, so I am using a fixed time-step ...
11
votes
2answers
3k views

Which of these two codes are 'better'? Making a local variable or a class variable?

Im making more games and asking more stupid questions. Hopefully this one is very brief. I'm making a very basic class which just moves a Player object by applying force to a rigidbody, but it got me ...
0
votes
1answer
76 views

How do I deal with closely coupled systems in a game engine?

Let's say a game engine had a central game class as well as multiple systems (as objects) that are stored within it. These systems (such as input, rendering, sound, etc) would also be updated by this ...
0
votes
2answers
72 views

How to set up a key press to start the game

I've tried to create a simple start menu for my game which informs the player to press a key to start the game but the problem is that it works only if the key is pressed all the time...i'm not sure ...
1
vote
1answer
163 views

Getting multiple inputs in C++ simultaneously using kbhit() function

I am using Turbo C++ to make a game using the graphics.h library (I know it's a bit old). In this game, the player can move left, right and they can jump using A, D ...
5
votes
1answer
144 views

How do games implement client/server frame rate?

Do games have a frame rate at X fps that updates logic and also renders? Or do games update logic at a much slower frame rate than rendering? Let's say 20-25 fps for logic, and 60+ fps for rendering....
1
vote
1answer
42 views

Can I implement allocation-free time releated event scheduler via pure C#?

I read some article about a gameloop, based on Actor system. (yes, it is Development & Deployment of Multiplayer Online Games Vol.2 by 'No Bugs' Hare) Here is pseudocode. ...
0
votes
1answer
17 views

In random loop button dont work properly

I have this code to add 10 point if someone click the button and change the question. But it returns 10 point every time. I want to make it 10,20,30,40... etc. ...
0
votes
0answers
16 views

Audio and Game play synchronisation techniques

I'm trying to develop an audio rhythm based 2d html5 game and need some advice. I'm trying to develop the logic to sync the audio with the games animation. I do not need a constant animated sequence ...
0
votes
1answer
44 views

Java advice (Printing game data to the window)

Does anybody know the best method for taking game data and setting up java to read the data then print it to the window... of which you want the game loop to start the game and read the data... Here ...
0
votes
1answer
67 views

Should I send the elapsed time to the fixed step update function from my game loop?

I am making a basic game loop based on this article. This is the nearly final version: ...
0
votes
0answers
73 views

Architecture and the gameloop

For the game I am making I think it would be best to implement an N-Tier architecture. The reason being is that I learned at school having a seperation of your UI, Logic and Classes is best in big ...
5
votes
2answers
2k views

OpenGL - How come drawing sprites takes so much performance

I'm wondering how drawing simple geometry with textures can eat up so much performance (below 60fps)? Even my good graphics card (GTX 960) can "only" draw up to 1000 sprites smoothly. The textures I'm ...
0
votes
2answers
114 views

Latency issue on multiplayer game networking

I am currently writing a 2D top-down shooting multiplayer game using Java. I have a game loop at the client-side that does the following in order in each game tick (The client is running in a tick ...
1
vote
1answer
106 views

Box2D simulation running slower on lower FPS(even when the desired FPS is lower than the actual)

I´m playing around and trying to make myself an easy platformer using the Box2D physics, before that I was not using it and was using my own physics implementation(just simple movements with timestep)....
0
votes
2answers
117 views

How to handle component-based objects in a game loop?

I've been writing my own game engine and I was wondering the correct way to handle my game objects. Each game object is different. The only thing they have in common is a set of operations to handle ...
-1
votes
1answer
169 views

Is my frame rate being calculated correctly?

I'm having a long headache (which may not be that complicated) with this frame rate thing. I already tested several frame rate algorithms, lastly I tested this here and they all gave something strange ...
1
vote
0answers
241 views

Help designing Board game using LibGDX

Hi i'd just like to preface this by saying i'm new to game development and currently learning the ins and outs of libGDX. I want to create the board game scrabble however i'm having trouble figuring ...
1
vote
2answers
38 views

In track and field dash, determine starting speed from a final time with acceleration

I am developing an athletics game, and working on the mechanics of the 100 meter dash. The player controls an athlete, that during the race has acceleration and a max speed. To win the race, the ...
7
votes
1answer
421 views

How can City-sim simulate hundreds of characters?

My games usually start lagging quite easily when there are a couple hundred of boxes representing possible characters. While games like SimCity or even Anno have hundreds of characters. I realized ...
3
votes
2answers
141 views

Is single/double frame allocator suitable only for POD datas?

Let´s say I have a single frame stack allocator, so I´m using it for allocating memories for my temporary data. ...
2
votes
1answer
147 views

Screen objects sometimes not rendering

I am a mildly experienced programmer who has created several game engine templates and small 2D games in Java. I am currently expanding to 3D game engines and I am re-writing a previous engine to be ...
1
vote
1answer
4k views

Proper use of async, await and task.delay for a game loop

I'm currently in the process of making a game loop in a console application. I'm trying to make the game loop wait at the end of its loop for ...
0
votes
1answer
17 views

Moving object with preset timelapse

I am a newbie game developer. I have one problem. Consider the following case. I have a simple game with only one object - a ball. A ball can move only up and down from one side to another. A User ...
0
votes
1answer
60 views

Screen size independent movements

I am developing a simple game for Android. It is a really simple game, with only one object - a ball. I am using the game loop based on delta time. However I have noticed that my game runs not in ...
0
votes
0answers
39 views

Fixed time for game to model physics

I am a newbie game developer. I need to develop a simple 2D game, it is really simple. I have a Human model that should jump every n seconds. User sets different several options in settings. The ...
2
votes
0answers
277 views

Framerate independent realtime input

I am currently working on a fighting game (with 3d graphics, gameplay like a 2d fighter) and encountered a pretty big hurdle I currently don't know how to deal with. For fighting games, input ...
5
votes
1answer
317 views

How can I make the main game loop frame-rate independant?

I am trying to create a frame independent game loop. I am currently using the following code ...
2
votes
1answer
385 views

Game AI architecture for a RTS game

I am developing a RTS (real-time strategy) game involving robber and cops. I have designed a simple rule based AI system for the robber. Goals of the robber AI: Escape from the cops (robber should ...
6
votes
3answers
194 views

How and when should I update events occuring after a while?

This question is not language specific but a more generic approach on how to deal with lazy updates for some game variables. Let's say, for instance, that I want to implement a "character age system" ...
1
vote
1answer
137 views

Timestep with multithreading

There are several questions and articles which deal with timestep - for example: Should game logic update per second or per frame? https://gafferongames.com/post/fix_your_timestep/ Accounting for ...