threads_this_02.gm 432 B

123456789101112131415161718192021222324
  1. global robot = {
  2. x = 50, y = 100, name = "robot"
  3. };
  4. global player = {
  5. x = 150, y = 200, name = "player"
  6. };
  7. global move_ent_left = function()
  8. {
  9. print( "Starting thread - this.name = " + .name );
  10. while( this.x > 0 )
  11. {
  12. this.x = this.x - 10;
  13. print( this.name + " - x = " + this.x );
  14. yield();
  15. }
  16. print( "Ending thread - this.name = " + .name );
  17. };
  18. robot:thread( move_ent_left );
  19. player:thread( move_ent_left );
  20. sleep(1);