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

I need help understanding why objects are not drawing to canvas [closed]

So I’m getting back into coding and using Pygame plus a pygame coding book to learn. I’m about 185 lines in this lesson where I’m making a pong like game. All object to be drawn on the canvas have ...
0
votes
0answers
15 views

SFML: Object's shape not rendered on the window

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 ...
0
votes
2answers
68 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
1answer
76 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,...
0
votes
2answers
95 views

When does a "frame" start and end?

Here is the main loop that I currently have (and it does work perfectly): ...
0
votes
0answers
42 views

How to design Smooth Game Play using the Windows message translator and message dispatch loops?

In gameplay, my sprite will pause briefly when I change directions. I need help correcting this issue. Any suggestions are welcome. I have a constants header that has ...
1
vote
1answer
130 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 ...
0
votes
2answers
93 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 ...
0
votes
0answers
69 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: ...
1
vote
1answer
73 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
1answer
49 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
0answers
26 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
1answer
91 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
102 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
4answers
341 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
126 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
88 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
75 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
62 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
28 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 ...
0
votes
2answers
116 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? ...
14
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
0answers
119 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
70 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
48 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
38 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
73 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
227 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
55 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
121 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
98 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
222 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
78 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
392 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
26 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
305 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
36 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
228 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
40 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
506 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
532 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
400 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
90 views

Game loop stutters

I have the following game loop: ...
0
votes
1answer
3k 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
657 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
457 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
443 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
367 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
79 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 ...

1
2 3 4 5
9