Results 1 to 3 of 3

Thread: Understanding window processing.

  1. #1

    Understanding window processing.

    I wasn?¢_Tt sure which group to post this in, but since I?¢_Tm still experimenting with DelphiX and you're all so clever and attractive... :-)

    Bit of a newbie regarding windows processing..

    Suppose I have a DXtimer running the game loop but I want another routine to calculate something (which might take a couple of seconds), but I still want my game to run as smoothly as possible while it?¢_Ts working.

    At the moment everything freezes and waits for the procedure/s to return.

    How should I approach this?

  2. #2

    Understanding window processing.

    You could put the procedure in a separate thread. The easiest way to implement threads in Delphi is to create a descendant of the TThread class and override its Execute method. When you create an instance of your TThread descendant, this method is executed in another thread, while your main program continues running.
    However, this can cause a lot of other problems, since you have to ensure that two threads are not accessing the same variable at once. What does this routine do that takes so long anyway?
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  3. #3

    Understanding window processing.

    Quote Originally Posted by Useless Hacker
    What does this routine do that takes so long anyway?
    Well I've been experimenting with a pathfinding routine found elsewhere on this site.

    I have a complicated 100x100 level grid (walls/blank areas etc) and a monster that wishes to travel to several different locations.

    Most of the time the calculation for the next path is quick, but occasionally it takes a second or two. so instead of everything freezing I wanted the monster to sit still while it calculates the path, leaving the player to move around.

Bookmarks

Posting Permissions

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