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.

learn more… | top users | synonyms (1)

12
votes
1answer
627 views

Behavior Trees :: Actions That Take Longer Than One Tick

From what I understand on Behavior Trees, each Behavior should be a short goal oriented Action that could be done in a few iterations. So for example, below is an image of a Behavior Tree: Now let ...
1
vote
1answer
891 views

CPU usage, game loop and sleep()

I've read about this topic on numerous discussion sites, but I can't seem to find a clear definitive (up-to-date) answer, and hopefully this will me some more insight: I've read the excellent game ...
-1
votes
1answer
181 views

Server fixed timestep not running at 30Hz but way way too fast [closed]

I'm trying to make my game's server thread run at a fixed 30Hz but can't figure out how. Basically, before I just had a stupid while(1) { //do everything as fast as you can} which means that for my ...
3
votes
1answer
503 views

Weird stuttering with fixed-timestep, variable-framerate game loop

I've been trying to set up fixed-timestep loop for my game, using the technique from here. I have no need for the interpolation step as I intend to run the logic at or above vsync speed. Here is a ...
-1
votes
1answer
196 views

Drawing multiple sprites with clear screen for every frame

I googled with best of my skills, but I cannot find any relevant answer to my problem. I'm making a game with an isometric view. I need to draw multiple sprites on the screen and before switching to ...
2
votes
1answer
170 views

Selecting the entities needed for rendering [duplicate]

Currently I'm sorting and looping every entity on my level but I really don't need to. Only a small subset would be on screen. If I could extract a list of entities from my main list that are on ...
2
votes
1answer
316 views

Synchronizing input, update and rendering threads

How do you synchronise the input-handling, state-updating and rendering threads? If a sprite position is modified due to input, the wrong position of the sprite might be drawn to the screen if the ...
10
votes
3answers
1k views

EXTREMELY Confused Over “Constant Game Speed Maximum FPS” Game Loop

I recently read this article on Game Loops: http://www.koonsolo.com/news/dewitters-gameloop/ And the recommended last implementation is confusing me deeply. I don't understand how it works, and it ...
3
votes
3answers
348 views

How precise should timers in update loops be?

What is the suggestion of "enough precision" in a timer for a fixed game update loop? Currently I'm testing with this code, but it sometimes misses 1-2 updates @ 50hz. While at 30hz it seems to work ...
2
votes
2answers
378 views

How do I calculate consistent frame timings at 60fps?

I'm writing an HTML canvas game that uses requestAnimationFrame and therefore runs at 60fps, although this is more of a question about failing arithmetic than about JavaScript. If I measure the time ...
4
votes
4answers
19k views

Android game scrolling background

I'm just trying to figure out the best approach for running a scolling background on an android device. The method I have so far.... its pretty laggy. I use threads, which I believe is not the best ...
4
votes
1answer
394 views

Online card games: game loop or event based?

The only games I've made have been the game loop variety. I'm just starting to think about building an online poker game where people could meet up in a lobby, etc. Cards seem event based... is the ...
4
votes
4answers
996 views

Creating the concept of Time

So I've reached the point in my exploration of gaming where I'd like to impliment the concept of time into my little demo I've been building. What are some common methodologies for creating the ...
1
vote
1answer
700 views

XNA - moving the 3rd person camera

I'm having following problem: Can't set my camera to follow object from behind and rotate when I use left/right arrow. I've tried different tutorial and examples but it still doesn't work for me. ...
13
votes
2answers
1k views

Design of a turn-based game where actions have side-effects

I am writing a computer version of the game Dominion. It is a turn-based card game where action cards, treasure cards, and victory point cards are accumulated into a player's personal deck. I have the ...
1
vote
1answer
548 views

SDL2 focus lost = massive gain in FPS

Whenever I lose focus from my game window, I go from ~60FPS to 6000+, then when the window gains focus again, I go back to around 60 frames per second. And yes, this happens every time I run my game, ...
13
votes
3answers
849 views

Game loop, how to check for conditions once, do something, then not do it again

For example, I have a Game class and it keeps an int that tracks the player's lives. I have a conditional if ( mLives < 1 ) { // Do some work. } However this condition keeps firing and the ...
5
votes
2answers
237 views

Simultaneous events in a realtime system, where processing order causes different outcomes

I am working on a realtime dungeon crawler, focusing on a relatively complex and flexible skill system. Somewhat similar to MMORPGs with many compound spells, area effects, buffs/debuffs, ect. I am ...
16
votes
9answers
1k views

How do I best remove an entity from my game loop when it is dead?

Ok so I have a big list of all my entities which I loop through and update. In AS3 I can store this as an Array (dynamic length, untyped), a Vector (typed) or a linked list (not native). At the moment ...
7
votes
2answers
3k views

Server side game loop

Many java games use thread.sleep() to controll fps. Since the server does not display graphics, should the server game loop keep running just calculating delta time? Like this example: long ...
3
votes
2answers
344 views

Should I redraw every pixel?

For my first game I implemented a tetris clone in javascript. My "canvas" and an HTML <table> with every <td> representing a single block. Instead of having a gameloop redraw every single ...
3
votes
2answers
3k views

Calculating Delta time , what is wrong?

For 2 days now i am trying to calculate the correct delta time for my game , I am starting to getting crazy since i tried all the solutions that i found on the 5 first google pages... What is wrong? I ...
1
vote
3answers
128 views

Triggering State Changes with Health Counter

I'm developing a game where the player changes states as their health decreases. Below 50, it should trigger animation1. Below 30, it should trigger animation2. The problem is, I only want to trigger ...
2
votes
2answers
845 views

How to slow down a sprite that updates every frame?

I am going through a Allegro 5 tutorial which has a game loop. There is also a variable "active" which determines if a key is being held down. Thus if the left key is being held down active is on and ...
1
vote
2answers
1k views

Networking Client Server Packet logic (How they communicate)

I want to know what is the logic behind server client communication through packets for a real time game. for example the server sends x packets then the client receives x packets and processes them.. ...
-1
votes
1answer
179 views

2D Game Help In XNA

I'm making a game in XNA called The Adventure Of The Very Hairy Princess Fairy. The game is a "Sidescroller/Platformer" like mario but there is a problem. How do I attach a weapon to the player ...
0
votes
1answer
393 views

How to make this game loop deterministic

I am using the following game loop for my pacman clone: long prevTime = System.currentTimeMillis(); while (running) { long curTime = System.currentTimeMillis(); float ...
7
votes
2answers
2k views

Multi threaded game - updating, rendering, and how to split them

From the StackOverflow post (it was recommended I move this): So, I'm working on a game engine, and I've made pretty good progress. However, my engine is single-threaded, and the advantages of ...
0
votes
1answer
349 views

Passing elapsed time to the update function from the game loop

I want to pass the time elapsed to the update() method as this would make easy to implement the animations and time related concepts. Here's my game-loop. public void gameLoop(){ boolean running ...
1
vote
1answer
786 views

javascript game loop and game update design

There is a main game loop in my program, which calls game update every frame. However, to make better animation and better control, there is a need to implement a function like updateEveryNFrames(n, ...
4
votes
3answers
683 views

What technology would you use to communicate between an iOS game and a Lua-based AI server?

What technology would you use to communicate between a two-player,turn-based, board game (like checkers or Othello) running native on iOS, and a remote game server The remote game server is just the ...
2
votes
2answers
1k views

Turn-based Strategy Loop

I'm working on a strategy game. It's turn-based and card-based (think Dominion-style), done in a client, with eventual AI in the works. I've already implemented almost all of the game logic (methods ...
1
vote
1answer
255 views

random spike in delta time

The title pretty much sums it up. I'm using delta time to move my objects and every few seconds the delta time will spike and all the objects will jump forward. Should I just Interpolate the delta ...
1
vote
2answers
268 views

what is the best way to use loops to detect events while the main loop is running?

I am making an "game" that has pathfinding using pygame. I am using Astar algo. I have a main loop which draws the whole map. In the loop I check for events. If user press "enter" or "space", random ...
4
votes
3answers
495 views

Best practices on separating Update and Draw on game loop

I've been working on my first HTML5 prototype and I found a good model that uses the regular Update and Draw loop we see in game dev. My question is, where does one end and the other begins? The ...
3
votes
1answer
944 views

Why is the framerate (fps) capped at 60?

ISSUE I recently moved a project from my laptop to my desktop(machine info below). On my laptop the exact same code displays the fps(and ms/f) correctly. On my desktop it does not. What I mean by ...
2
votes
2answers
1k views

Why does my game loop speed vary on different platforms with the same hardware?

I've got a serious issue with my game loop. This loop varies in time with the platform and with the same hardware. This is a list of FPS achieved: - Windows ======= 140 to 150 - Linux ...
2
votes
0answers
341 views

What is wrong with my game loop/mechanic? [closed]

I'm currently working on a 2d sidescrolling game prototype in HTML5 canvas. My implementations so far include a sprite, vector, loop and ticker class/object. Which can be viewed here: ...
1
vote
3answers
1k views

Android, how important is deltaTime?

Im making a game that is getting pretty big and sometimes my thread has to skip a frame, so far I'm not using deltaTime for setting the speed of my different objects in the game because it's still not ...
3
votes
2answers
419 views

Explaining Asteroids Movement code

I'm writing an Asteroids Atari clone, and I want to figure out how the AI for the asteroids is done. I have came across that piece of code, but I can't get what it does 100% if ...
0
votes
2answers
407 views

how to get started with a game engine [closed]

I'm a 3rd year Computer Science student and I would like to get started with building a game engine or at least tinkering with making one. I am curious if there are any good resources to use to get ...
0
votes
2answers
422 views

Negative timeout value in Variable Timestep loop

I was working on my game loop and I came across an odd problem. The loop was working fine, my states could render, received updates, etc. I then proceeded to create my Input system, which, also works. ...
1
vote
1answer
417 views

How to precisely limit fps

I am having trouble making my game's main loop to run at exactly N fps. Let's say i want game to run at constant 60 fps. Here is part of my code: int ticksPerSecond = 60; int skipTicks = 1000 / ...
0
votes
1answer
662 views

Java2D Game Flickering

I'm in the process of trying to get familiar with making games in Java, using the Swing library. Coding my Snake game however, I've got to a point where the game is flickering/ghosting and I haven't ...
1
vote
1answer
576 views

User input in game loop

I am building a simple multi-player fly-around-a-3D-world game in Javascript/webGL/websocket (Chrome, Firefox mostly). How should I handle and process user input? My preliminary design (untested) is ...
0
votes
1answer
409 views

Rendering Loop Problem (Java)

I'm not new to programming, but I am relatively new to game programming. I am trying to create a version of Breakout, as a good basic game to get myself introduced to 2d game programming. I currently ...
1
vote
2answers
163 views

Benefits of implementing systems like classes instead of just functions

In an Entity System I am making, there is a central class called World, which stores all component instances. It's a dictionary-of-arrays, and entity ids are indexes for the arrays. To access a ...
3
votes
4answers
649 views

Game loop alternatives for efficiency

Understand where I'm coming from - I've been taught that a game is implemented something like this (pseudocode): while (!win_condition) { waitforinput(); updategraphics(); //etc.. } exit(); ...
7
votes
2answers
555 views

Replay system: record inputs or events?

I read this: How to design a replay system But it don't really answer my question. My game is built with the client "view" of the game as a separate program from the server "model" and "controller". ...
4
votes
2answers
332 views

What would be the problems with using a singleton design pattern for my engine?

I'm desiging an HTML5 2D game engine in Javascript, and currently, I use the singleton pattern. There is only one global object in the namespace called simply Engine. All other objects are ...