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.
7
votes
2answers
487 views
Java 2D game programming: Different approaches to make a game loop
I am new to Java game programming, but the more I read the more I'm confused, because I've seen several different approaches to make a game loop:
1. The standard approach, that uses the Timer class ...
0
votes
2answers
101 views
Android Loop : Draw Loop : How to pull off smooth FPS?
I am writing 2D side scrolling bullet hell-like game.
I am at a point where I struggle to pull off smooth fps.
I have separated loop that manages drawing.
However I want update the position of ...
0
votes
1answer
509 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 ...
0
votes
2answers
75 views
Serious gameplay issue by spawning enemies according to elapsed time
EDIT: I have changed the title as I think that this is a general gamedevelopment question but, on a technical note, I am using Cocos2d v2.0
Some time ago I had asked a question on which was the most ...
0
votes
2answers
94 views
C# Cursor stuck on busy state
So I implemented a fixed time step loop for my C# game. All it does at the moment is make a square bounce around the screen. The problem I'm having is that when I execute the program, the window ...
1
vote
1answer
89 views
Picking game entities
What is the preferred methods for doing so, performance-wise?
For example I want to pick certain objects in an area around a given point.
What I have thought off so far is using invisible objects as ...
1
vote
2answers
74 views
Game loop delta, factoring execution time?
Was thinking this morning, I 99.9% of the time, only see a main game loop, looking like this, just as much so where the delta is passed into update():
while running
getDeltaTime()
...
f(deltatime)
...
-2
votes
1answer
109 views
How to add difficulty levels to a Guess The Number game using rand()? [closed]
User guesses a random number (between 1 and 100 or 5000 and 25,000 depending on difficulty) that the computer picks.
User selects difficulty from list, difficulty (1, 2, 3, 4) is assigned to int ...
0
votes
0answers
18 views
Time on touch events?
Whats the best way to have a touch even cause an action for a specific period of time or deltaTime?
It seems like it should be simple, but I have tried while and for loops based on int counts for ...
0
votes
1answer
27 views
Removing drawn Allegro texts and primitives
I'm working on a game with Allegro 5 that has a loop. I'd like to make the program write onto the screen, how much time the loop has ended. These are the rounds of a turn-based game, obviously. I use ...
1
vote
0answers
47 views
Accessing variables from non-neighbouring classes specifically in game development (Android)
Edit
Using direct access while breaking the law of demeter looks like this:
res.sprite.drawQuad(res.sprite.xScreen,res.sprite.yScreen, mMVPMatrix);
Using proxy methods / getters / setter looks ...
-2
votes
0answers
71 views
How to Fix Choppy Movement [closed]
I've just started game programming yesterday, reading things here and there on the internet, and I've been testing the java 2D API.
The code below does basically what I want it to (move the red ...
5
votes
1answer
194 views
Android game loop's effect on cpu/battery usage - unexpected results
I will try to keep this question as concise and as readable as I can.
I recently came across an odd problem with my Android game that I'm developing.
It's an openGL ES 2.0 game and initially I was ...
-1
votes
1answer
92 views
Get distance between the edge of screen and a moving sprite
How to get the distance between the edge of the screen and a vector moving sprite? I want to get the distance between my moving sprite and the edge of the screen so that when my sprite touches the ...
0
votes
6answers
763 views
Avoiding constant IF checks for loops
As an example, I have 3 different loops that are executed in certain conditions.
I want to know if there's any way short of something like this:
if(day)
x++;
else if(night)
y++;
else
z++;
...
1
vote
2answers
459 views
Why are my game ticks longer than expected?
I was working on my game, adding stuff to it, when I noticed my ticks were in the low 50's when I had set it to do a constant 60. This is my run method.
public void run() {
init();
long ...
2
votes
2answers
125 views
Correct utilisation of gameloop (Android)
When using a gameloop like (much simplified)............
updateLogic();
render();
How does one perform 'single' operations? I mean, things like triggering sounds (which will only be played once), ...
1
vote
0answers
110 views
How to implement a multi-platform Java 2D game engine's graphics?
I'm not sure whether this question should be posted here. I'm trying to make a basic generic game engine in Java. Here's what I have so far.
public abstract class Device {
public abstract void ...
0
votes
0answers
104 views
Android OpenGL ES 2.0 gameloop problems
I implemented a gameloop found here: http://www.koonsolo.com/news/dewitters-gameloop/ into my OpenGL ES 2.0 Android game. The tutorial was written with the canvas API in mind, not OpenGL so I made a ...
-2
votes
1answer
51 views
how to restart in java japplet? [closed]
how to restart a game? problem with my code is that when it restarts it double the enemy. so there are 10 enemies and lets say player dies than user restart and now there are 20 enemies and so on.....
...
1
vote
1answer
87 views
Gamemaker Loop Question
How often do loops repeat in game maker? Is it every step, or as fast as it can handle? I need it to loop every step, is it possible to do that? I'm talking about in code, I have a do until loop. Just ...
2
votes
2answers
167 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? ...
7
votes
4answers
495 views
Simultaneous game states
I think I understand the basic idea behind a Finite State Machine-based game loop. But I'm trying to write a little game in which the same object can simultaneously be in multiple, independent states. ...
-1
votes
1answer
71 views
simple win32 window wont show [closed]
The program compiles and runs successfully but does not show a window, it simply ends immediately.
#include <Windows.h>
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, ...
3
votes
2answers
133 views
Behavior Tree Iteration Rate
How is a Behavior Tree iterated in a game? For example, let's assume you have an extremely large Behavior Tree with about a hundred Actions/Conditions. If we were to run one action or condition ...
1
vote
3answers
228 views
Whats an elegant implementation for 2D collision detection in a block based game?
to make things clear, i do not want to know HOW to implement collision detection mathematically. What i am looking for is an elegant way to check for collisions without having to manage seperate lists ...
3
votes
1answer
253 views
The most efficient and accurate game loop?
Obviously for a game to work you need a game loop... Normally, my game loop would consist of something like this:
while(running){
update();
render();
Thread.sleep(10);
}
This seemed to ...
-6
votes
1answer
95 views
Generic Class Name for RTS [closed]
Hopefully this will be a nice easy question :-
I am building an RTS as a way of learning OOP techniques.
Currently the code has the following classes
Class MustInherit GameUnit
Class MustInherit ...
7
votes
1answer
213 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
288 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
126 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
140 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
111 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
123 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
198 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
587 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
253 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 ...
3
votes
2answers
265 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 ...
3
votes
4answers
14k 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 ...
2
votes
1answer
216 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
915 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 ...
0
votes
0answers
71 views
Using boost function to wrap execution of a boost signals2 signal
I am considering using the boost library to design a simple yet effective callback event notification framework for my game application. The idea is that objects that can raise events would have a ...
1
vote
2answers
184 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
267 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. ...
12
votes
2answers
640 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
260 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, ...
11
votes
3answers
603 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
0answers
140 views
Implementation of Race Game Tree [closed]
I build a racing game right in OpenGL using Glut, and I'm a bit lost in all the details. First of all, any suggestions as a road map would be more than great.
So far what I thought is this:
Tree ...
5
votes
2answers
180 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 ...
15
votes
9answers
972 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 ...
