home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / colobotdemo / colobotdemo10e.exe / help / cbot / dist.txt < prev    next >
Encoding:
Text File  |  2001-07-02  |  1.1 KB  |  31 lines

  1. \b;Instruction \c;distance\n;
  2. With the instruction \c;distance( , )\n; you can calculate the distance between two positions.
  3.  
  4. \b;Basic use
  5. If you write \c;position\n; alone, this gives you the position of the bot that executes the program. If you write the name of a variable followed by \c;.position\n;, this gives you the position of the object described in the variable.
  6.  
  7. Here is a program that moves forward, covering exactly the distance between the bot and the closest ant:
  8. \c;
  9. \s;    item = \l;radar\u cbot\radar;(AlienAnt);
  10. \s;    \l;move\u cbot\move;(distance(position, item.position));
  11. \n;
  12. This is of course pure suicide. Better to stop 40 meters before, in order to be at shooting range:
  13. \c;
  14. \s;    item = radar(AlienAnt);
  15. \s;    move(distance(position, item.position) - 40);
  16. \n;
  17. \b;For specialists
  18. Syntax:
  19. \s;\c;distance ( pos1, pos2 );\n;
  20.  
  21. Calculates the distance between two positions. 
  22.  
  23. \t;pos1, pos2: \c;\l;point\u cbot\point;\n;
  24. Coordinates of the two positions. 
  25.  
  26. \t;Return value: \c;\l;float\u cbot\float;\n;
  27. Distance between the two positions.
  28.  
  29. \t;See also
  30. \l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.
  31.