   How would you get a game to do multiple things at once?
  I''m trying to plan out an RTS game, and I''m trying to determine how to set up my engine. The way it works out in my head right now, if I wanted to move a unit, I''d tell them to go there, and I''d have a pathfinding function. So in psuedocode I''d have:Scan all available unitsif(selected)   MoveTo(point);  But the problem with that is that nothing else in my game would be able to do anything until that unit had finished moving. 
  Set each of your objects up with a target point they are moving to, or current behavior, etc. and iterate each object''s behavior every game tick.  When an object reaches its destination, its data should tell the game that it is no longer moving, so that when it comes time to iterate its behavior again, nothing happens. ;  Don''t move a single unit all the way to its destination all at once.  Write your pathfinding algorithm so that it can give you the next step to take en route to your destination.  You can then loop through each unit and move it one step, then repeat the loop and move each unit another step, etc. etc.You''ll need some sort of main game loop that calls various user input functions and graphical update routines once per frame, as well as the AI and game object update code.  Every frame, update the state (position, health, etc.) of all your units by one ''step''.  The state of a unit should include its destination, so you can have some units moving, others stationary or doing other activities.  At any time, the user input funciton can change the destination or activity of a unit, and the pathfinding algorithm should give a new ''next step'' for the unit to take to get where it''s going. ;  That''s was I starting to think of. I was going to give each object a ''state'', and call a function to check the state each pass through the game loop; then act upon that state. ;  The biggest problem will not be the moving, but rather, the pathfinding.  I think the AI forum has posts about pathfinding sometimes, if you need some ideas. ;  Thanks. I''d already started to write one when I got bored in my CS class. It''s kinda basic and crude but I think it''s a good start, and it works, so that helps. ;D ;quote:Original post by Sfpiano  That''s was I starting to think of. I was going to give each object a ''state'', and call a function to check the state each pass through the game loop; then act upon that state.   This revalation is about as significant as the one where you realize that no, you actually can''t make your entire game out of nested if''s.... At least, it was for me... ;  Haha. Sad but true. Oh well, better now then week before a real project is due. 