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)

2
votes
2answers
365 views

Lockstep Game Loop

I have an XNA game using a basic lockstep update loop. The client sends all commands to the server, and updates only if it has received the next turn's commands from the server. When does a turn end? ...
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
356 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
1answer
3k views

Android: Improving surfaceView?

I'm using Surfaceview in my Android app. I have two threads, one for UI and another for rendering and updading the UI. I am limiting my frames per second to 30 fps and have employed frame-skipping ...
2
votes
2answers
410 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
1answer
416 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 ...
1
vote
2answers
330 views

Multiple pipelined game loops

I am considering using the following game engine design pattern, but I am unsure if it's a good idea or not: Each major task (drawing, physics, logic, networking, disk I/O) will have its own ...
1
vote
1answer
770 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. ...
1
vote
1answer
566 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
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 ...
5
votes
2answers
242 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 ...
13
votes
3answers
929 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 ...
0
votes
1answer
486 views

Am I doing this node.js game loop wrong?

I have 2 arrays of JSON objects, actions and game objects. At any time a user can make a request from the client which can add an action to the actions array. I have a setInterval(function(){ }, ...
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
352 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
986 views

HTML5/JS - Choppy Game Loop

I have been experimenting with HTML5/JS, trying to create a simple game when I hit a wall. My choice of game loop is too choppy to be actually of any use in a game. I'm trying for a fixed time step ...
3
votes
2answers
4k 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
129 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 ...
1
vote
1answer
162 views

Problem with Scanner class in Java [closed]

I'm pretty new here (as though to a game development). So here's my question. I'm trying to organize a really simple game cycle in my public static main() as follows: Scanner sc = new ...
2
votes
2answers
930 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
180 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
435 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 ...
0
votes
1answer
410 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
833 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, ...
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
264 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
283 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
520 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
1k 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
3answers
1k views

Speed, delta time and movement

player.vx = scroll_speed * dt /* Update positions */ player.x += player.vx player.y += player.vy I have a delta time in miliseconds, and I was wondering how I can use it properly. I tried the ...
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
443 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
425 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
497 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. ...
2
votes
1answer
338 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 ...
1
vote
1answer
448 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 / ...
1
vote
1answer
604 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
721 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 ...
0
votes
1answer
436 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
164 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
675 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
608 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
340 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 ...
2
votes
2answers
424 views

Is using a dedicated thread just for sending gpu commands a good idea?

The most basic game loop is like this : while(1) { update(); draw(); swapbuffers(); } This is very simple but have a problem : some drawing commands can be blocking and cpu will wait ...
1
vote
3answers
768 views

My rhythm game runs choppy even with high frame rate

EDIT: [SOLUTION] I posted a possibly explanation for my issue below to anyone who has a similar problem. Hope it helps. I'm coding a rhythm game and the game runs smoothly with uncapped fps. But when ...
2
votes
1answer
313 views

Handling various frame layouts in Android

I am trying create a Contra or the old TMNT game (but a simple one) like game for Android. For the game I decided to divide my main screen in three parts - upper for stats, mid for the game and lower ...
-2
votes
1answer
184 views

Issues with networking in my Java game, Client crashes when I try and read from the server input

A buddy and I have been programming a code game over the last 2 weeks, it is intended to be a multiplayer game with the ability to have 2 players play against each other. I am running into an issue ...
1
vote
1answer
3k views

AS3 Calculating Delta Time In Seconds

Here is how I've been trying to implement delta time based on different internet resources. var startTime:Number = getTimer(); game.Update(deltaTime); deltaTime = Number(getTimer() - startTime) * ...