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.
0
votes
1answer
84 views
Where do I handle my input in a basic game loop?
I recently had the occasion to work on a game during a gamejam at my college and it really got me into it so I've decided with a friend of mine to start something more polished. During the gamejam, I ...
0
votes
1answer
96 views
Game Loop, Deltas. What is wrong?
For my Android app this is the gameloop:
public void run(){
while(true){
if(frames == 0)
cTime = System.currentTimeMillis();
if(System.currentTimeMillis() >= ...
0
votes
0answers
30 views
SDL: Trouble targetting window from inside of another class
I'm a beginner to SDL and also pretty new to C++ in general, so please go easy on me.
Below is a very basic game loop I've been working. I have no errors when compiling, however my grass texture in ...
0
votes
1answer
56 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
48 views
How do i get the drawing to loop automatically with out need for user input scrolling?
#include <iostream>
#include <time.h>
#include <iomanip>
#include <SDL.h>
#include <stdlib.h>
#include <string.h>
#include "screen.h"
#include "Stars.h"
#...
3
votes
1answer
89 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 then scale your calculations based on that -- this is essential for ...
0
votes
1answer
45 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:
while (true)
{
System.Threading.Tasks....
0
votes
1answer
91 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 ...
0
votes
0answers
63 views
Efficient use of database in game loop
I'm trying to write a simple browser based style game (I say browser based style because I'm running it all locally). The game is a real time strategy in which player control towns and armies and try ...
0
votes
1answer
136 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 it will always be called with the ...
64
votes
5answers
7k 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:
while(running)
{
processInput();
while(isTimeForUpdate)
...
0
votes
0answers
46 views
A central game controller responding to events vs global event system
Say you have combat mechanics and your projectile object fires an EnemyHit game event. You'd like to hook up a UI element indicating damage numbers. I've got two options:
Receive that event in my ...
0
votes
2answers
138 views
Implementing “Fix Your Time Step”
So far I have this implementation of "FYTS".
However I am facing several problems.
final int TICKS_PER_S = 60;
double accumulator = 0.0;
//The timestep
final double dt = 1/(double)...
0
votes
0answers
62 views
How to slow down snake without making it collide with itself?
I just finished writing my first game ever, snake, in lua using Love2D. The entire source is here: https://github.com/AriaFallah/snake.
Here is the problem: My snake is made of 10px by 10px segments, ...
2
votes
1answer
63 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'...
1
vote
0answers
34 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
32 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
71 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
44 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
63 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
141 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
54 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
204 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
140 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
85 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
86 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
51 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
168 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
157 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
49 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
147 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
189 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
76 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
44 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
54 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
195 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
171 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 ...
2
votes
2answers
263 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
105 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
1answer
523 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
68 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
1answer
146 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
131 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
233 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
53 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
255 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
65 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
162 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
502 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
133 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 - ...