Jump to content
  • Advertisement
Sign in to follow this  
alee

about threading

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

Hi, I am total noob to this field and i was thinking, rather confuse about game design. We see number of objects(characters) in a game moving or acting. Do all these characters have their own thread? if not then how can all these move simultaneously?

Share this post


Link to post
Share on other sites
Advertisement
No, generally you just move every object slightly every 60th of a second. So your loop looks like this:


while (game is running)
{
for each object in the world { move object }
for each object in the world { draw object }
update sound, network, controls etc.
}

Share this post


Link to post
Share on other sites
Quote:
Original post by alee
Hi,

I am total noob to this field and i was thinking, rather confuse about game design.

We see number of objects(characters) in a game moving or acting. Do all these characters have their own thread? if not then how can all these move simultaneously?


The reality is they don't all move at the same time. What really happens is you move everything one at a time OFF screen in a "screen buffer." Then when your all done the image you made off screen is moved(flipped) to the visible screen.

Logic is handled in small pieces. You break up all your tasks in to small moments. Instead of doing all of one big action you do only a little of all actions. For example you don't drive a car across town all at once. You tell it to keep driving a little at a time until it gets across town. At the same time you tell the bird in the sky to move only a little toward his goal.

So you drive your car just a little, move you bird just a little, Draw them both off screen, then move your work to the visible screen. Do this a few times a second and suddenly it looks like the car is driving and the bird is flying all at once.

Make sense?

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!