Jump to content
  • Advertisement
Sign in to follow this  

game loop

This topic is 4823 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

Advertisement
I think this depends on your type of game? Are you looking at something with a Large AI? (unlikely, we're talking needing a long loop) or are you looking at "if the guy is there and I can shoot, shoot) Likely just make a quick function that has all the enemy possiblities, tests and though patterns?

Share this post


Link to post
Share on other sites
Since we are at the topic of the game loop. .....
There is a rule for us programmers ( eerr.. actually YOU programmers! ) not to have our functions longer than the size of our window and be able to see them without scolling our window. But in a game loop there are many thing to do, so you know that the loop ( not even the function ) will be longer than what the screen can show. Should we care?

thanks...

Share this post


Link to post
Share on other sites
Quote:
Original post by valla2
Since we are at the topic of the game loop. .....
There is a rule for us programmers ( eerr.. actually YOU programmers! ) not to have our functions longer than the size of our window and be able to see them without scolling our window. But in a game loop there are many thing to do, so you know that the loop ( not even the function ) will be longer than what the screen can show. Should we care?

thanks...


Well it's not a "rule" but it's good practice to keep your functions relatively short (maybe less than 50 lines). You can always call other functions within the function to reduce the size of it.

Share this post


Link to post
Share on other sites
Quote:
Original post by valla2
Since we are at the topic of the game loop. .....
There is a rule for us programmers ( eerr.. actually YOU programmers! ) not to have our functions longer than the size of our window and be able to see them without scolling our window. But in a game loop there are many thing to do, so you know that the loop ( not even the function ) will be longer than what the screen can show. Should we care?
You delegate responsibility for those things out to sub-functions. One clear job per function keeps thing nice and simple.

Share this post


Link to post
Share on other sites
Quote:
Original post by valla2
yes.. and the game loop prevents the programmer from doing so...


No, it doesn't. We call our functions from within the loop. We can even have additional loops within the game loop.

Share this post


Link to post
Share on other sites
Ahem.

General rule is, have as many functions as possible. Function is good if you can describe it in one short sentence.

But that produces many function calls and that costs one memory cycle each (a lot of wasted CPU cycles).

I suggest putting "inline" infront most of your functions you know you'll call many many many times in very short periods and give compiler a hint that can really speed up some loops or iterations. Search through web or MSDN for "inline" keyword explanation.

To exclude myself from flaming (again), anyone please correct me if I'm wrong, cause I use inlines often with such designing pattern when doing speed-critical software, ie. games.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!