Move A to B coding

  • helmut
  • Newbie
  • Newbie
  • helmut
  • Posts: 5

Post 3+ Months Ago

Say, the client sent a Move X2 Y2 command to the server. Server receive that mssg and execute Move(X2,Y2) function. The point will then move from the original point X1, Y1 to X2,Y2 . While travelling towards X2,Y2, client sent again a new point which is Move X3, Y3. Server receive it, and somehow it should stop the point which is moving towards X2,Y2, and from that position, initiate the move so that , the point will now travels to X3,Y3.

heh.. i hope u all can understand that. Well, my problem is.. the code i've written, will only move towards the point X3,Y3 , after it reaches X2,Y2 point.

I'm using Kdevelop , n currently writing for a real-time network game.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

What control type are you using within the function? If you are using while you could include an and statement in the conditions to check to see if "and no other call to move point exists" (I only know php and that would look like this):

Code: [ Select ]
while ($move = 1 && empty($move2)){}


You could also include an IF statement that would check each time it looped to see if there were any new values, maybe in an array instead of two different variables...

Hope that gives you some ideas.
  • helmut
  • Newbie
  • Newbie
  • helmut
  • Posts: 5

Post 3+ Months Ago

I have come out with an idea of using thread to solve this. As in, create a thread n perform the move. If a new coordinate detected for that moving point, it will kill that thread ( making it stop moving ) n initiate a new thread that will move that point to the new position. Anyone can help me on how to kill a thread base on its id number ?

int thread_id;

thread_id = pthread_create( xxx, xxx, xxx , xxx) ;

pthread_kill(thread_id, 0 );

?????

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 106 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.