Tagged Questions
64
votes
3answers
13k views
Tips for writing the main game loop?
Can anyone recommend some good tips, articles, sites, etc. for writing the main game loop? What are some things that you should do in the game loop, and what are some things that you shouldn't do in ...
20
votes
2answers
1k views
Several classes need to access the same data, where should the data be declared?
I have a basic 2D tower defense game in C++.
Each map is a separate class which inherits from GameState. The map delegates the logic and drawing code to each object in the game and sets data such as ...
13
votes
3answers
3k views
Finite state machine in C++
So, I've read a lot about using FSMs to do game state management, things like what an FSM is, and using a stack or set of states for building one. I've gone through all that. But I'm stuck at writing ...
13
votes
2answers
715 views
Where should collision detection logic be placed?
I am developing a small 2D game engine. The characters have a paint method which currently does the following:
Calculate the new position of the character as per its speed, etc.
Update the collision ...
12
votes
5answers
741 views
Game actions that take multiple frames to complete
I've never really done much game programming before, pretty straightforward question.
Imagine I'm building a Tetris game, with the main loop looking something like this.
for every frame
handle ...
10
votes
2answers
3k views
how should i develop my android game efficiently?
I have attached a image of a flow chart that i made in paint.
The image shows how i want to develop my game. I want a game that runs great with smart coding that is easy to update and ad features ...
10
votes
3answers
527 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 ...
8
votes
4answers
928 views
Using idle time in turn-based (RPG) games for updating
If you take any turn based RPG game there will be large periods of time when nothing is happening because the game is looping over 'wait_for_player_input'. Naturally it seems sensible to use this time ...
5
votes
2answers
309 views
Draw and update order in 3d graphics
In all of the code samples that I have looked at, the game loop looks something like this:
while(true)
{
InputAndUpdate();
Draw();
SwapBuffers();
}
However doesn't this destroy ...
4
votes
3answers
751 views
Deal with mini states in game
Hi :)
I want to ask what is the best way to deal with "mini-states" in game? For example I making game like Simcity, i can build buildings, roads, rails, or I can change something in economy.
I am ...
4
votes
2answers
260 views
How to store the state of the world for a fixed time step?
Most of the posts on fixed time steps say something like this:
State previous;
State current;
while ( !quit )
{
double newTime = time();
double frameTime = newTime - currentTime;
if ( ...
3
votes
2answers
549 views
Designing the Update system (read very basic game engine) for an XNA game
I am trying to determine the best way to implement the "update" system or engine for a simple XNA game.
Description of situation
I have a few classes, lets call them
Player [will be an ...
2
votes
2answers
96 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
2answers
433 views
Entity manager loop opinions
This days I'm refactoring code and one of the things I want to improve is my entity manager code. More precisely, the update funcion where entities are updated. My engine is a 2D tile based engine ...
1
vote
1answer
235 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 ...