Jump to content
  • Advertisement
Sign in to follow this  

GameLoop source review...

This topic is 2341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font=verdana, geneva, sans-serif]Hi~~~[/font]

[font=verdana, geneva, sans-serif]Today is hard day :([/font]

[font=verdana, geneva, sans-serif]Sooooo hard :(:(:([/font]

[font=verdana, geneva, sans-serif]This is GameLoop the best post !!!!!
http://www.koonsolo.com/news/dewitters-gameloop/ [/font]

[font=verdana, geneva, sans-serif]In this post, "Constant Game Speed independent of Variable FPS"[/font]

[font=verdana, geneva, sans-serif]const int TICKS_PER_SECOND = 25;
const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
const int MAX_FRAMESKIP = 5;[/font]

[font=verdana, geneva, sans-serif]while ( GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP )

[font=verdana, geneva, sans-serif]next_game_tick += SKIP_TICKS;

[font=verdana, geneva, sans-serif]Please Look bold...[/font]

[font=verdana, geneva, sans-serif]I don't understand...[/font]

[font=verdana, geneva, sans-serif]What does mean "GetTickCount() > next_game_tick && loops < MAX_FRAMESKIP" ?[/font]

[font=verdana, geneva, sans-serif]How many "Update()" call ?[/font]

[font=verdana, geneva, sans-serif]Why ? next_game_tick += SKIP_TICKS;(==40 Tick)
Why add 40 tick ?[/font]

[font=verdana, geneva, sans-serif]I don't understanding really...[/font]

[font=verdana, geneva, sans-serif]I do not know how to be to find information.[/font]

[font=verdana, geneva, sans-serif]Please let me us.....

[font=verdana, geneva, sans-serif]It's so hard......[/font]

Share this post

Link to post
Share on other sites
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;



//rendering took 200 ms
renderTimePos += 200;

while(logicTimePos < renderTimePos) update_game(), logicTimePos += logicTimeStep;
[/source] Edited by eppo

Share this post

Link to post
Share on other sites
I have written an article that tries to explain this concept a little more clearly, with graphics to make it clear.

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

Share this post

Link to post
Share on other sites
[font=verdana, geneva, sans-serif]

@eppo, @L.Spiro[/font]

[font=verdana, geneva, sans-serif]

Really Thanks you so much.[/font]

[font=verdana, geneva, sans-serif]

I Will try very hard to read and try to solve the problem ^^a[/font]

[font=verdana, geneva, sans-serif]

Thanks more ~~~[/font]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!