Jump to content

  • Log In with Google      Sign In   
  • Create Account

GameLoop source review...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 AquaMacker   Members   -  Reputation: 255

Like
0Likes
Like

Posted 16 July 2012 - 01:39 AM

Hi~~~

Today is hard day :(
Sooooo hard :(:(:(

This is GameLoop the best post !!!!!
http://www.koonsolo.com/news/dewitters-gameloop/


In this post, "Constant Game Speed independent of Variable FPS"

const int TICKS_PER_SECOND = 25;
const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
const int MAX_FRAMESKIP = 5;


while ( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP )
{
update_game();


next_game_tick += SKIP_TICKS;
}


Please Look bold...

I don't understand...

What does mean "GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP" ?
How many "Update()" call ?
Why ? next_game_tick += SKIP_TICKS;(==40 Tick)
Why add 40 tick ?


I don't understanding really...

I do not know how to be to find information.

Please let me us.....
Please.....


It's so hard......

Sponsor:

#2 eppo   Crossbones+   -  Reputation: 2621

Like
1Likes
Like

Posted 16 July 2012 - 05:42 AM

The idea is to let the games logic/physics run at a fixed (say 40 ms) interval and the renderer at the best it can come up with (say it manages only 5 fps).

So whenever rendering is finished, logic-time needs 5 steps to overtake (you make the assumption the next frame will take 200 ms to render as well).

Perhaps you find this a bit more readable:
[source lang="java"]renderTimePos = 0;logicTimePos = 0;logicTimeStep = 40;loop{ render_game(); //rendering took 200 ms renderTimePos += 200; while(logicTimePos < renderTimePos) update_game(), logicTimePos += logicTimeStep;}[/source]

Edited by eppo, 16 July 2012 - 05:48 AM.


#3 L. Spiro   Crossbones+   -  Reputation: 14263

Like
1Likes
Like

Posted 16 July 2012 - 07:43 AM

I have written an article that tries to explain this concept a little more clearly, with graphics to make it clear.
http://lspiroengine.com/?p=378

If you can read it you should be able to understand everything.
Because it is long, I will tell you to look mostly at the section called “But How Can That Work? Don’t I Need to Know its Next Position, Not its Last Position?” and the graphic in that section.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#4 AquaMacker   Members   -  Reputation: 255

Like
0Likes
Like

Posted 16 July 2012 - 05:48 PM

@eppo, @L.Spiro

Really Thanks you so much.

I Will try very hard to read and try to solve the problem ^^a

Thanks more ~~~




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS