Several events at a time?

This is a discussion on Several events at a time? within the Game Programming forums, part of the General Programming Boards category; How can i make my programm do several things at a time? F. ex. two units move at the same ...

  1. #1
    Registered User MathFan's Avatar
    Join Date
    Apr 2002
    Posts
    190

    Several events at a time?

    How can i make my programm do several things at a time? F. ex. two units move at the same time. Should i make an array with functions that have to be executed?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    You can't do several things at the same time, however with good structuration of your program you can make it look like it.
    Code:
    void MainGameLoop()
    {
       HandleInputFromKeyboard();
       HandleInputFromMouse();
       MovePlayer();
       MoveEnemy1();
       MoveEnemy2();   
       HandleCollisionTests();
       RenderScreen();
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    multithreading.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Multithreading AND more than 1 processor.

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    You don't need multithreading or multiple CPUs. The types of
    things he's talking about are simple AI movement calculation,
    sprite movement, hit point calculation functions, etc. Basic game loop functions. Magos' answer summed it up.

    MathFan, your game will execute several functions inline in the
    main game loop. These functions will be so small and require such
    little execution time that they can all execute seemlessly. Your
    game loop will probably execute anywhere from 30 to 90 times
    per second, so you won't be able to tell that the functions are
    being executed one at a time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Representing floats with color?
    By DrSnuggles in forum C++ Programming
    Replies: 113
    Last Post: 12-30-2008, 09:11 AM
  2. seismic events program
    By santaclaus in forum C Programming
    Replies: 16
    Last Post: 11-23-2003, 03:23 PM
  3. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 07:17 PM
  4. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21