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.

1
vote
2answers
39 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 ...
8
votes
1answer
528 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
209 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
197 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
6k 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
19 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
71 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 ...
2
votes
0answers
391 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
387 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
460 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
195 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
193 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 ...
2
votes
2answers
381 views

Using an interpolated game loop (such as Gaffer's final game loop), will the frame be rendered out of sync?

A highly recommended game loop is one from an article called Fix Your Timestep. It presents a method to update using a semi-fixed time step with interpolated rendering. The problem with this is that, ...
0
votes
1answer
150 views

How can I make the Player animation appear smooth?

I'm using GLFW for my window and input related work. I'm calculating delta time and multiplying it with my player speed and then finally adding it to the current position of the player. The thing is ...
0
votes
1answer
88 views

Character jumping but not returning to ground platform game AS3

I am making a platform game where the main character moves right and left and jumps however my character jumps and does not return to the ground but stays on top of the stage.My characters movie-clip ...
0
votes
1answer
268 views

How to manage changing Z-Index in an Entity-Component-System?

If got an Entity Component System based game-project (like classic zelda). The Player as well as Enemys are Entities with sprite- and tranform-components. The Weapons are also Entities with sprite- ...
0
votes
1answer
322 views

What functions should be called in C++ gameloop from Lua Script

I am using sol2 lua wrapper for my 2D game-engine to implement some lua scripting,but I have some questions about what should functions should i call from Lua scripts in c++, and i cannot find any ...
0
votes
1answer
642 views

Is this paint method okay?

I dont know why i need to call super.paintComponent() and super.repaint() to make the player's movements update, if i just put paintComponent the game seems like to always be stopped. However I think ...
0
votes
1answer
494 views
2
votes
1answer
1k views

Game loop with multithreading

I have learned how to create and manage threads in C++. Now I'm trying to create game loop based on multithreading but I can't imagine how should I split whole game to tasks. I mean, should rendering ...
0
votes
1answer
426 views

Function call time

I'm making a game and I want an update method to be called every 120th of a second. I've looked up timers but they start the timer after the function has returned, but I want the timer to start when ...
1
vote
1answer
74 views

requestAnimationFrame handles game ticks weird when tab isn't viewed

So i have the game logic and render in the callback for requestAnimationFrame, and somehow the ticks run very weird. In fact, the rendering happens alright. But the ticks seem to skip an ...
1
vote
2answers
692 views

Java - Why does my game loop stutter randomly?

I'm a beginning game developer and I'm trying to make a game in Java, but for some reason, it keeps stuttering at random times. I believe what I'm experiencing could also be called microstuttering. ...
0
votes
1answer
297 views

Is this a good Java gameloop?

I wonder if this gameloop in Java is accurate to give around 60 frames a second, is it? ...
0
votes
1answer
50 views

Changing the current state of an entity in the middle of an update step or wait for the end?

Let's say that I use a behaviour component that holds a function call to be called every update step assigned to an entity. Inside that function call I'm changing the active state for the entity to ...
1
vote
1answer
267 views

Why does my Java game loop randomly jump to 62 FPS and crash?

I've been working on a Java game, but I couldn't keep it from stuttering. I did some research, and found out that I was using a bad game loop. I've been working on a new game loop, which works a ...
0
votes
1answer
629 views

Is there a way how to handle multiple SDL_PollEvent loops without clearing the event queue?

Is there a way how can I handle more SDL_PollEvent while loops for one SDL Event, without taking the events off from the event ...
0
votes
2answers
459 views

BufferedImage canvas is null

I'm sorry if this isn't the right place for this post, but I don't know where to go. I'm trying to make a simple game loop but it's already failing ...
1
vote
1answer
799 views

Game Loop delay the right way and game speed

I am a newbie game developer. I am trying to find a right way to create my game loop. Consider following example. Simple Android Game I have a game with a simple gameplay - bouncing ball. I want ...
0
votes
2answers
143 views

Do I still need limit FPS when I have a variable timestep?

Lets say I have a simple game loop (variable timestep - but it applies also for other timesteps): ...
0
votes
1answer
457 views

Where do I handle my input in a basic game loop?

I recently had the occasion to work on a game, during a game jam at my college, and it really got me into it, so I've decided to start something more polished with a friend of mine. During the game ...
0
votes
1answer
153 views

Game Loop, Deltas. What is wrong?

For my Android app this is the gameloop: ...
2
votes
1answer
239 views

How much do inconsistencies in update timing matter?

Yesterday I wrote my first game loop with fixed timesteps. It is supposed to run every 50 ms, however it runs at 50-53 ms. Does it matter? I'm guessing no, but I figured I would ask anyway. ...
1
vote
1answer
61 views
2
votes
1answer
278 views

Framerate-independent game loops and discrete tasks

When writing good framerate-independent game code, you take some sort of deltaTime parameter in your main render() function and ...
0
votes
2answers
71 views

How do I pass my objects to the update method?

I've had formal education in Java for around half a year now, and as a hobby I would like to attempt game development. I've downloaded the Slick2d library to help with this. I've run into a problem ...
0
votes
1answer
388 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: ...
0
votes
1answer
315 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 ...
1
vote
1answer
2k 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 ...
74
votes
5answers
13k 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: ...
2
votes
2answers
1k views

Implementing “Fix Your Time Step”

So far I have this implementation of "FYTS". However I am facing several problems. ...
2
votes
1answer
113 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'...
0
votes
2answers
221 views

Prevent rendering queue from overflowing when using Vsync

My game loop currently looks something like this: ...
0
votes
1answer
89 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
131 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 ...
0
votes
1answer
139 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
654 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. ...
1
vote
1answer
457 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: ...
2
votes
2answers
1k views

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

Here's my game loop: ...
2
votes
1answer
237 views

Smoothness & performance issues of new game [closed]

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 ...