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.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
109 views

Why process physics before the variable framerate update in a game loop?

As far as I know, most game loops are executed in the following order: Process user input Update (once per frame) Physics (also known as fixedUpdate, 0 to N times ...
2 votes
0 answers
37 views

Backend architecture for multiplayer browser text game with a short gameloop

This is my first foray into game-dev and I only have webapp experience professionally. I'm creating a browser game in nodejs/react. It is mostly text-based, so no intensive graphics (think chess.com ...
0 votes
0 answers
99 views

How to implement an attack with a real-world duration like in Clash of Clans?

I wanted to understand how a strategy game like Clash of Clans would implement the attack. Clash of clans is just an example I am taking but I am interested in understadning logic of attack in any ...
  • 101
2 votes
1 answer
103 views

How to deal with mismatch between fps and monitor refresh rate?

Say I have a game running at some number of frames per second on a 60 Hz monitor. I would like to display my frames correctly in the sense that the in-game time difference between two consecutive ...
0 votes
0 answers
42 views

FPS Counter not printing out into the console

So I've been trying to make a FPS counter for my custom game engine, but I can't seem to get the game loop to run the FPS counter. I even tried to debug the code, but it keeps saying like "input....
0 votes
1 answer
33 views

Pygame, jump counter resetting on first button press

Been learning my first platformer game based on this tutorial. I decided I wanted to go off book and make it so the player could jump a second time before hitting the ground. I used the blit function ...
0 votes
0 answers
31 views

Streaming animation data via WebSockets

I have a 3D character model and I am streaming animation frames from a server to the client via a WebSocket (I am using three.js). I need some advice on how to correctly integrate the streaming data ...
  • 1
0 votes
0 answers
81 views

How can I render a texture in a specific x/y position on the screen? (OpenGL - glium)

I am in the process of writing a 2D game in Rust, and decided to use glium for the graphics part. So far I'm doing fine, able to render textures and shapes ...
0 votes
1 answer
51 views

How to measure deltaTime? [duplicate]

I'm trying to make a simple console application and don't want to use Unity, but I want to implement a timer, so I would want to use Time.deltaTime.
0 votes
0 answers
22 views

Signalling time-expiry to clients in a browser-based multiplayer game

I'm trying to develop my first ever browser-based multiplayer game that utilizes my own websocket server which has no multi-threading capability. It will be a game where players try to be the fastest ...
0 votes
2 answers
160 views

Game loop c++ implementation

I'm starting to develop some simple 3D game. The basic topic for a start is the game loop. There is a solution: ...
0 votes
2 answers
76 views

Understanding User Input Behind the Scenes?

I am a bit confused on how user input is actually received and processed behind the scenes in a game engine. Let's say I have a simplistic game loop as follows... ...
  • 101
1 vote
0 answers
226 views

How to make an update loop in a Node.js game server

I'm making a multiplayer game with a Node.js server, and I'm searching for how to write the game loop. I'm currently using a setinterval every 15ms, but someone ...
1 vote
1 answer
181 views

How to synchronize the main thread (rendering, 60 FPS) with the game logic thread (10 FPS)

I wrote some games years ago, and they were always in sync with the main thread. So, for example if the monitor refresh rate is 60 Hz it would look like below. ...
  • 11
0 votes
0 answers
40 views

SurfaceView shows black screen

My code does not work correctly. SurfaceView shows a black screen instead of Bitmaps. I make a game loop that doesn't depend on CPU, like Fix Your Timestep!, but I can't get it to work. ...
  • 1
0 votes
0 answers
48 views

SurfaceView gameloop

Could you suggest an implementation of a game loop with interpolation for SurfaceView and thread? i have this, but it doesnt work. ...
  • 1
0 votes
2 answers
109 views

How to reconcile collision detection with delta time?

In my simulation, if an object is inside another object, it imparts a force proportional to the distance inside the object (basically a separation force). I am having an issue though where the ...
0 votes
1 answer
102 views

Large Armies fight : Looping through a million elements

I'm currently developing my first game. I had the idea to do something similar to the old browser games like Ogame, Travian, etc (with some differences though), and I'm kind of unsure about how to ...
  • 1
1 vote
3 answers
193 views

What can help make my Resource-Management game into a FUN game?

I am working on a "life simulator" resource-management game where the player has to go to work, go studying, pay rent,... and basically increase his resources and use them to unlock perks, ...
  • 1,382
0 votes
0 answers
35 views

Javascript Game Collision Shaking

I have a problem with collision shaking. The problem doesn't come from the collision, but from client side (sometime the it's smooth and sometimes not). Here is a video to show it : https://www....
0 votes
1 answer
93 views

Proper way to handle user input when the game is lagging

I was just learning game programming concepts and was confused on what is the correct way to handle user inputs. I am used to javascript, so all the below snippets are in js but I assume the concepts ...
0 votes
1 answer
49 views

SFML: Object's shape not rendered on the window [closed]

I want to be able to render sf::CircleShape (representing pointwise charges) when pressing mouse buttons on the window. The problem is easy enough, however the ...
user avatar
0 votes
2 answers
94 views

Naming convention for loop modules

Question about game engine object oriented design. Let’s say I have an engine with a main loop, and many handlers that will be executed by the main loop every time on next iteration of main loop. So ...
1 vote
1 answer
103 views

One global game loop vs multiple local game loops

What are the advantages of using multiple game loops instead of one? Assume Level1, Level2, Level3. These levels may bring totally different problems and needs and they may also be completely separate,...
user avatar
0 votes
2 answers
118 views

When does a "frame" start and end?

Here is the main loop that I currently have (and it does work perfectly): ...
1 vote
1 answer
246 views

Multithreading vs Asynchronous game loop for multiplayer online game?

I'm trying to create a turn based multiplayer online game where players can be grouped in a room/lobby and play (similar to Ludo but number of players can be more than 4). There can be multiple such ...
  • 111
0 votes
2 answers
170 views

Structuring a game in Java

I am currently programming my first game in Java and I'm having trouble structuring it. My biggest concern is regarding the game loop. Currently I have implemented a class with only a main function ...
  • 1
0 votes
0 answers
110 views

Game loop design

I'm developing a simple Win game. Here is my 2 similar implementations of the game loop (in c++): approach #1: ...
  • 101
1 vote
1 answer
136 views

Where should I handle player movements in a Java Game?

I had an old pure Java 2D top-down game that I'm trying to reformat a bit. Before, I had a bit of a messy game loop that didn't use delta timing for any movements or animations. Now, I'm trying to ...
0 votes
1 answer
82 views

DeltaTime is smaller than it should be

I have a gameloop for a simulation I'm making, I noticed that the simulation is going very slow, When i checked the DeltaTime it was very small, I set the target fps to be 1 (deltatime should be 1 in ...
0 votes
0 answers
28 views

Organising gameobjects into multiple lists

I have a very simple little game that consists of a player, zombies, food, and treasure. It's all automated. The player will walk towards a zombie and shoot within a certain distance, which costs ...
0 votes
1 answer
134 views

Why does the triangle rendered by OpenGL ES 2.0 , with SDL 2.0 context, vanishes after a single render, if events are not polled?

I was experimenting with OpenGL ES 2.0 and being new to OpenGL, I was trying to render a simple triangle. But I was shocked to see that, if I do not call ...
0 votes
1 answer
143 views

Should a server run all maps in one loop, or a thread/game loop per map?

I'm working on a real time multiplayer browser-based game. The game is top down on variable size tile based maps. There is no central map where all players come together, the entire game plays out in ...
0 votes
4 answers
761 views

Should I bother with SDL_WaitEvent?

When I wrote my first application in SDL, it looked like this: while (!quit) { SDL_PollEvent(&event); switch (event) { // ... } } But ...
  • 173
0 votes
1 answer
299 views

Sever-side physics simulation and client 'inputs' send rate in a fast multiplayer game

I am building a very tiny first-person multiplayer game. I'm just aiming to get the basic rights: client-side prediction and reconciliation + entity interpolation. I have read many articles on these ...
0 votes
0 answers
189 views

Game loop implementation

I'm implementing simple Windows game. Here is my game loop, which I've written based on some tutorials found on the Web: ...
  • 101
0 votes
1 answer
122 views

Timers: check in game loop, or run independently?

Specifically talking in the context of JavaScript game development. For example, I can use the language specific timeout mechanism: ...
0 votes
0 answers
107 views

Are you supposed to be looping through all PhysicsObjects at every step in a physics engine?

I am currently making a small 2D game and I am trying to implement some basic 2D physics. I currently have a list of around 100 PhysicsObjects which I loop through every frame in order to update and ...
0 votes
1 answer
45 views

Is it okay to update the graphical handlers in the same function where you render them?

I have a class called 'GraphicalHandler' that all my graphical handlers inherit from the main game loop. The class manages a static vector of pointers to all instances of itself. I can then call the ...
  • 145
0 votes
2 answers
138 views

How can I handle input in C without halting the main loop?

I want my C program to update the console every second, and it was working fine until I tried to handle input. Now the program halts since it waits an input from the user. How can I do this? ...
  • 35
15 votes
3 answers
5k views

Fixed timestep game loop, why interpolation

This is a very standard way of doing a fixed timestep game loop, where you just accumulate time from the previous frame and consume it in discrete steps with the physics engine: ...
  • 163
0 votes
0 answers
166 views

How to implement jumping on the left and right?

I am trying to make a platform game in C++ and SDL2. I tried to add a jump in the update() function of the main code below , but it does not work as expected, as you can see in the video: Note: I did ...
0 votes
3 answers
87 views

Java - how to reduce iteration loops for enemies

I have many places in my code where I'm iterating through the enemies array and it seems to me it could be optimised somehow, but I can't see how it can be done. For example these two loop checks: <...
  • 195
1 vote
1 answer
52 views

The gameloop is stucking the window

I tried to display a player image in a 800x600 window using PyGame but when I try it, the window just gets stuck (immovable with mouse drag, minimize,maximize and close button is stuck and not ...
user avatar
0 votes
0 answers
63 views

Texas hold'em game logic loop

Ok, so I was thinking of making a Texas Hold'em game, and I wanted to write down the game logic loop before starting. Here's what I have. Tell me if I missed anything or if anything is wrong. Game ...
  • 1
0 votes
0 answers
98 views

The Command pattern and multiple inputs per frame?

I'm reading Game Programming Patterns by Robert Nystrom. As a test I've implemented the command pattern, but a little farther in he changes it to return commands, rather than instantly executing them. ...
  • 1
0 votes
0 answers
385 views

Game server multiplayer architecture

I'm planning to build a big browser multiplayer game with gameplay very similar to agar.io but rpg. Game will be containing rooms as It's done in agar.io. 50-100 players max per room. Realtime. 10ms ...
0 votes
1 answer
67 views

How to disable pause() in game_loop() once game_over() function is called?

How can I disable pause() in game_loop() once game_over() function is called? game loop ...
0 votes
1 answer
153 views

Functions in the game loop

I'm learning about the game development. No i'm on the total basics - writting a proper game loop. As i've searched over the Web i'v found that simple but good ...
  • 31
0 votes
0 answers
186 views

Java game loops with high tick times?

Take for example the first game loop from this question. A similar code is used in Minecraft (at least in older versions). I understand the concept and how this loop works in principle. But there is ...
  • 101

1
2 3 4 5
10