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
-2
votes
0answers
63 views

Game loop in C for SDL game

I need to create a menu for my game but in game loop this is where i get stuck and don't know where to put my menu and where game a how to do when i click play the menu dissapears and game shows up. <...
0
votes
1answer
33 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
1answer
70 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
3answers
76 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 ...
0
votes
1answer
50 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
0answers
67 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: ...
0
votes
1answer
58 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
0answers
45 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
1answer
22 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 ...
-1
votes
2answers
98 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? ...
13
votes
3answers
4k 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: ...
0
votes
1answer
78 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
3answers
59 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: <...
1
vote
1answer
42 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 ...
0
votes
0answers
19 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 ...
0
votes
0answers
51 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. ...
0
votes
0answers
119 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
1answer
42 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
1answer
87 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 ...
0
votes
0answers
59 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 ...
0
votes
1answer
96 views

Calling function every n second javascript game

I making a game and I want to call a function that runs every random second to spawn something every time. I've seen some posts that said to use the setInterval() ...
0
votes
0answers
56 views

Game Rooms Server Architecture - ENet CSharp

My team and I are working on an upcoming online fighting game using ENet-CSharp (A C# ENet implementation created by nxrighthere), and we're currently designing the architecture of the server. We ...
1
vote
1answer
181 views

Entity component system: how and where store pointers to system resources or third-party lib's objects?

I'm migrating my game pet-project to ECS. I use C# (custom-made engine, not Unity). It goes pretty well, but one big thing is making me worry. This is how and where to store pointers to system ...
1
vote
0answers
24 views

Unity problem with instantiated objects when destroyed

So this is my problem, I have a square that when destroyed spawn 4 smaller squares when shooting on it, but when I shoot one of the 4 smaller squares sometimes a different square that are not even ...
1
vote
1answer
129 views

My HTML Canvas went blank

I tried to draw Mario Sprites in my HTML Canvas, but it always went blank. Anybody knows why? ...
0
votes
1answer
30 views

I can't clear the paint image in my Canvas

I'm trying to make the Mario move, but somehow it leaves traces behind, can anybody help??? ...
0
votes
0answers
143 views

Best game loop architecture

So I understand how a game loop works (listenInputs/updateData/redrawInterface) but what I'm struggling with is how am I supposed to equalize rendering? I initially thought I had to make the thread ...
0
votes
0answers
73 views

How does Quake II 'sleep'?

I'm looking through the Quake II source code and I cannot understand how the game implements sleeping. Here's how I understand the Windows main loop: Inside the loop it sleeps if the game is ...
0
votes
0answers
36 views

My server simulation is getting locked up between receiving movement input from players and updating projectile position

I'm currently developing a 2D game in the browser with Nodejs and Canvas. Im simulating the world state in the server side with a timestep of 60 frames per second. Im only sending a snapshot of the ...
5
votes
1answer
339 views

How do open world game engines allocate memory?

My troubles I've been trying to create a game engine but since I am not well experienced in C++ I am having trouble deciding on how to load new scenes efficiently level by level or just an open world. ...
0
votes
1answer
525 views

How often should I check for collisions in a Miinecraft-like game?

I'm trying to build a game from scratch in Dart, similar to Minecraft. As far as I understood, there are two main functions in a general game loop: tick: a function that gets executed a fixed ...
0
votes
1answer
278 views

How to slow down my Variable Timestep Loop in Java

I am currently developing a game in Java and I ran into a problem At first, I thought my game loop was working well as it was giving a similar amount of FPS as the tutorial I was following Then I ...
1
vote
0answers
81 views

Game loop stutters

I have the following game loop: ...
0
votes
1answer
2k views

Need help with an 'Exception thrown:write access violation:this was nullptr' in a c++ - SFML project

I'm currently learning how to program a 2d game with SFML using a tutorial series by Suraj Sharma.This's his channel: https://www.youtube.com/channel/UC2i39AOpDSlO1Mrn1jQ8Xkg The tutorial series: ...
0
votes
2answers
468 views

How to repeat scene in Unity 3D?

When my game ends I want it to automatically restart from the beginning so that the whole scene repeats itself. How do I do that in Unity 3D? Please refer this link for clarification.
3
votes
1answer
330 views

How to structure tic tac toe game loop (or equivalent simple turn based game)?

I'm developing the simple Tic Tac Toe game in Java and got stuck on the game loop architecture. The game must support local, remote and automatic players. The graphical interface is based on JavaFX. ...
0
votes
1answer
343 views

Moving an Enemy Toward the Player but only in cardinal+diagonal directions

I am working on a "quick project" to get my feet wet and to put something finished in my projects. I want to make an enemy that constantly tries to be aligned with the player object, but doesn't ...
4
votes
2answers
269 views

C++ Object management/deletion

I am working on a game with a lot of bullets, currently every second it loops through a vector of bullet objects and checks if its marked for erasure or not. ...
0
votes
1answer
56 views

Game server simulation loop updates to fast even if the fixed steps are implemented

Today I wanted to ask you about the server world simulation loop that I have implemented and it acts weird. I am using Java, LibGDX and KryoNet to create 2d rpg co-op game based on server-clients ...
0
votes
1answer
59 views

How can I make my animation switch frames automatically without pressing any keys?

So I have been trying to figure out for so long how I can loop the frames on my animation automatically without entering user input to prompt movement of my object. I have four different frames for a ...
0
votes
2answers
651 views

Implementing a main loop with rendering in a Windows Desktop Application

I'm writing the beginnings of a small game engine in Visual C++. What I have so far doesn't seem to be updating the rendering each frame, but I don't understand where I'm going wrong with it. The ...
1
vote
2answers
482 views

How to handle player input with fixed rate variable fps time step?

I've made a system which uses the ideas from "Fix your Time Step" in order update physics. I'm having trouble finding standard methods for dealing with this when user input affects player movement ...
0
votes
1answer
312 views

How does a game like Minecraft handle block and entity updates?

I am not asking how Minecraft loads chunks or generates chunks, I am asking about individual blocks and entities and their behaviours. Suppose you have a dirt block: dirt block can be converted to a ...
0
votes
1answer
134 views

Game loop inside libGDX game loop

I have the main game loop in libGDX. On the touch() event I want an animation to be executed. So I will have a variable which will store the value which will be ...
4
votes
2answers
104 views

Exchanging data between custom-built hardware and games

I have a built my own steering wheel and motion platform that I would like to connect to popular car racing games (e.g. iRacing, Dirt Rally). I need to read data such as the car's acceleration (to ...
4
votes
1answer
255 views

Fixed Timestep with Interpolation | Blurry & Choppy

I've been implementing a game loop with a fixed timestep which uses interpolation as described in the (legendary as I have come to find out as it is referenced in almost every post I have read trying ...
1
vote
1answer
105 views

Is it always necessary to synchronize rendering in a game loop?

When writing a game loop from scratch in java for an android game applications, it is very common in many tutorials I have read that the keyword synchronized is used to synchronize update and ...
0
votes
1answer
265 views

Web based poker on Phaser 3

Please can somebody help me as I'm a lil bit new to game dev and user interface designing. I am trying to create a simple Texas holdem poker using phaser3 for multiplayer application. I have a few ...
0
votes
0answers
75 views

How Best to Implement Fixed Time Step for Gsync/Freesync Monitors?

I currently implement my game loop using a variable fixed timestep, i.e. dt = 1 / monitor_refresh_rate with vsync (or pseudo vysnc with delays where vsync is ...

1
2 3 4 5
9