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
0answers
15 views
Prevent rendering queue from overflowing when using Vsync
My game loop currently looks something like this:
while (!quit) {
takeInput(); // Input is sampled however fast loop can run
time_now = get_time()
time_passed += (time_now - time_prev);
...
0
votes
0answers
24 views
Keeping track of space objects: enemies, projectiles, players
I have a Vector called spaceObjects of type SpaceObject that contains all types of SpaceObjects: Heros, Projectiles, and Enemies.
I've added all these to this one Vector because I'm passing it all ...
0
votes
1answer
61 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
30 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 main.cpp from player.cpp, so I can keep everything ...
0
votes
1answer
56 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
52 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.
using namespace System;
using namespace ...
0
votes
1answer
33 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:
var input = {};
while (!done) {
handleInput(input);
update();
render();
}
document.onkeydown =...
1
vote
2answers
133 views
Game Loop getting 58-62 FPS. Why not exactly 60FPS? (SDL/C++/OSX)
Here's my game loop:
uint64 target_fps = 60;
uint64 ticks_per_s = SDL_GetPerformanceFrequency();
uint64 target_ticks_per_f = ticks_per_s/target_fps - (ticks_per_s/1000); //aim for (target - ...
1
vote
1answer
76 views
Smoothness & performance issues of new game
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 ...
0
votes
3answers
72 views
Long delta time and collision detection
When player's computer stutters/he tabs out of game stopping requestAnimationFrame calls, movement system tied to the delta time creates a huge leap, bypassing probable collisions. This allows player ...
3
votes
2answers
63 views
Unity Animation Tracking
Background
I've recently reached a bottle neck in my game's code that forced me to completely decouple the logic/networking from the graphics. Thanks to the nature of my board game, I was able to ...
1
vote
2answers
45 views
Updating bots/AI behavior after a fixed elapsed timestamp in game loop?
I am developing a HTML5 game in javascript. Now I have created a few bots and they should be able to change their orientation after a few seconds/a fixed timestamp in the game loop.
Suppose my game ...
0
votes
2answers
72 views
How to kill a fired bullet sprite after certain amount of time in Phaser?
The bullet should be killed after it was shot from the player, and after a certain amount of time.
function create() {
bullets = game.add.group();
bullets.enableBody = true;
bullets....
8
votes
2answers
119 views
Fixed timestep with interpolation & rounding draw positions: jerky animation when the character is not moving
I've implemented a deterministic, fixed timestep system from here:
http://gafferongames.com/game-physics/fix-your-timestep/
Everything works fine, output is the same with each step but there's one ...
0
votes
0answers
39 views
Setting up game loop wait time and FPS
I have been able to set up the game loop method/function, but many objects do their stuff in separate threads. The reason for that is not ensure, that the program is not going to stop working, despite ...
1
vote
2answers
131 views
Game loop with fixed timestep gives strange result
So I've read the famous article at http://www.koonsolo.com/news/dewitters-gameloop/comment-page-2/#comments which describes different methods of implementing a game loop. I've tried to implement the ...
3
votes
0answers
133 views
Tick frame: update order problems
Sorry, it's a bit long story but I hope you can help me.
First of all: I have an entity class called SceneObject. The SceneObject has components (eg. RenderableMesh, Camera) and transformation data (...
0
votes
1answer
62 views
Creating 3D gravity in zero-G tied to mass in unity with c#
As a total beginner,
I've been working on a patch-job script for a gravity mechanic in an open space sim, I want to derive all my objects from this "Block ALPHA" object and its' set of variable ...
0
votes
1answer
31 views
Loop in coroutine stops after going halfway
I have a very weird problem with a particular loop in a coroutine:
public IEnumerator DestroyCubesGameOver() {
var startingCubeHolder = GameObject.FindWithTag("StartingCubeHolder");
...
0
votes
1answer
49 views
Is Update(GameTime) called before it's finished?
Code at the beginning of Update(GameTime) is being called over and over again, and code at the end of Update(GameTime) is only being called after a delay. Is Update(GameTime) called again before it's ...
0
votes
1answer
133 views
CPU and RAM usage in OpenGL too high in Swift
My game is set up so the the display controls the game loop, usual in Cocoa. The callback function calls run() which is this. The thing is, the thread running the callback is using 63% CPU and the RAM ...
0
votes
1answer
119 views
Why is my deltaTime in my GameLoop 0?
I have a question about my code. I wrote a basic GameLoop
for an Android Game and while testing it I realized the deltaTime
is always 0.
The code looks like this:
@Override
public void ...
1
vote
2answers
205 views
Game Loop design that is speed hack proof
I'm not sure if this is possible, but it's worth a shot asking. How does one design a game loop in such a way that hooking and enabling a speed hack app to the game(dx11) doesn't matter?
I found this ...
3
votes
1answer
93 views
Correct order of entity updates and collision detection
I'm trying to simulate a number of units walking in a single file. My update loop looks like this:
for each unit:
n = compute next position
if n is empty then move to n
If I start the loop ...
0
votes
0answers
31 views
Do I restart the service?
I have a long running service in my game, that consists of two threads.
//MY SERVICE:
if(userEnabledProcessOne) //Shared preference value that I'm getting from the settings of my app based on a ...
0
votes
1answer
292 views
Game loop architecture using WPF(MVVM) and C#
Could i get some suggestions on how to implement a game loop whilst using WPF(MVVM) and C#, I am a professional developer and understand the technology well.
The game loop usually contains a Init(), ...
1
vote
1answer
59 views
Repaint() in gameloop does'nt work [closed]
Recently I'm working on a PAC-MAN clone.
I created 3 classes:
StartingClass which extends Jframe and uses KeyListener
Board which extends Jpanel
Sparx which is responsible for changing the ...
0
votes
0answers
104 views
Custom game loop entirely in the Update method
I am attempting to implement a custom game loop in XNA/Monogame. I know that one can re-implement the Game class using WinForms (with the caveat of having to also redo the content manager, etc.).
I ...
0
votes
1answer
112 views
Organizing Setup(), Update() and Draw() function in a game engine
I'm creating my first game engine and I want help with organizing the Setup(), Update() and Draw() functions in the correct way.
Here is how my main() function looks like
/* BEGIN main() Function */
...
0
votes
1answer
94 views
How to Implement a Timer for my Prefab for Roll-a-Ball Game (C# in Unity)
I am trying to create a public float timer that senses when the particular prefab has not been there for a certain amount of time. Then, it will replace that particular object.
The goal is to ...
6
votes
1answer
221 views
How to execute game logic every 100ms but render as fast as possible?
I have created a simple snake clone and would like to execute game logic every 100ms while rendering as fast as possible. How can I achieve this when the program might run with very different frame ...
0
votes
1answer
45 views
Competing keyboard events
When I was looking on how to handle key inputs in a game loop I came across the following pattern: All native key events (up or down) get queued in an event queue that is later processed. The outcome ...
3
votes
1answer
209 views
How can I separate processing input and update?
I know that game loop is broken up into three distinct phases: processing inputs, update, and render, but I just can't see how I can make processing input and update independent of each other.
Let's ...
2
votes
1answer
62 views
Game loops using Hard realtime systems vs Soft realtime systems
I have read the article here about realtime systems and am looking for examples specific to game loops.
Am I correct in saying:
Hard realtime systems will lag and slow down gameplay causing slow ...
0
votes
1answer
101 views
Game Loop and Animation states/frames
I just wanna be straighforward. I read a dozen of articles talking about game loop, components, modules, structures, time control, etc...
But, in the end I'm still somewhat confused of how animation ...
6
votes
1answer
382 views
In JavaScript, should I write a game loop for a turn-based game?
I am using javascript and HTML5 canvas for turn-based games (e.g., checkers, mastermind, minesweeper).
Should I write a fixed-timestep game loop? What are the alternatives?
-2
votes
1answer
131 views
Why is my delta time constantly under 1 millisecond?
I have a game loop that looks like this:
while (Sync())
{
DoStuff();
}
The sync function computes my delta time like this:
bool Sync()
{
EndTime = GetTime();
DeltaTime = (EndTime - ...
0
votes
1answer
123 views
Most efficient way for nested loop to not repeat a value of parent loop in pair-wise structure (C# or Javascript) [closed]
It's hard to choose the correct title for this question, so let's see if I am able to better convey here what I am in search for. If the title is too far away, suggestions are welcome and I can edit ...
0
votes
0answers
33 views
Controlling when a Java game repaints
I've been learning how to program game loops lately and the issue I'm running into at the moment is figuring out how to repaint my window only when I tell it to. I suspect that my issue is not fully ...
1
vote
1answer
86 views
How should I define interaction modes in a strategic game?
I am creating a typical strategic game that gamer can select, deploy and move the game characters (Human mostly) and move or create buildings on its isometric map.
These all are going to be done by ...
1
vote
1answer
79 views
Basic game loop, what does Update() and HandleInput() mean to you?
I have been developing a game and until now I have been handling input like so:
Player presses a key
HandleInput() acknowledges a key is pressed calls a function within the Player class which ...
-1
votes
3answers
141 views
A method to create and assign a name to a GameObject (Unity)
I'm trying to create a function that takes in a name of an object in the editor and assigns this accordingly as well as the name of a sprite, rigidbody, etc.
Basically what I have so far is-
...
4
votes
2answers
280 views
Could someone help me understand this game loop logic?
I'm learning Java game development and trying to dissect this game loop:
// Game loop
final int TICKS_PER_SECOND = 60;
final int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
final int ...
1
vote
1answer
171 views
Implementing a modal dialog from scratch with C++
Right now I'm implementing my modal dialogs in windows with a separate message loop after popping up the dialog.
This straightforward an approach won't work with other systems that don't have message ...
4
votes
1answer
200 views
How can I show slow motion?
In my very, very simple 2D game I'm working on, I'd like there to be moments of slo-mo.
What is the best method of showing the player that the game is currently in slow-motion? As in, what is the ...
2
votes
1answer
375 views
Varying framerate (FPS) [closed]
In my game-loop, I am using fixed time step for physics and interpolation for rendering as suggested on Gaffer on Games | Fix Your Timestep!
However, when the framerate is varying between 30-60fps ...
2
votes
2answers
373 views
Laggy empty project at 60FPS
@Override
public void create() {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20....
1
vote
2answers
125 views
Should input be per-frame or per-update?
I'm implementing a GUI system to look around a 2D tile-based world. At the moment, I'm updating it every time the mouse moves (which happens to be per frame, since that's when it polls for events). ...
1
vote
1answer
78 views
Playing with hashmap in drawing
I'm developing a game in Java for Android, using LibGDX.
In my render(), between the batch.begin() and batch.end() I'm running through all the game objects and draw them.
Every game object is stored ...
2
votes
1answer
128 views
Client and server loops don't match up
I'm trying to build a small networked game using WebGL and NodeJS. I have a basic client and server setup and I'm at the point where I'm trying to implement dead reckoning to simulate what happens on ...