CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1

    Struggling with multi-threading...

    I am trying to write a game using the Allegro game programming library. I have a character class which I want to create six instances of. Each instance of the class is a separate character that needs to move at the same time as another, i.e. it is a racing game and all six characters will be racing one another.

    It seems to me that each character needs to move within separate threads from one another, each needs to move at different speeds, but concurrently.

    I have been trying to use boost threads to achieve this, but cannot find any tutorials to give me a hand.

    Is it possible to start a new thread calling a function that takes two parameters?

    The function within the object has the following declaration:

    Code:
    void Character::MoveOnY(BITMAP *tempBitmap, BITMAP *mainBitmap);

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Struggling with multi-threading...

    boost::threads operate on function objects called with no parameters. Any "parameters" must be stored within the object.

  3. #3
    Join Date
    Aug 2007
    Posts
    858

    Re: Struggling with multi-threading...

    There's no need for multithread for something that simple. Just look up how to use Allegro's timers and create a main loop that updates your game's logic at a consistent rate.

  4. #4

    Re: Struggling with multi-threading...

    Ok, thanks lindley and speedo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured