home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / colobotdemo / colobotdemo10e.exe / help / Tspid3.TXT < prev    next >
Text File  |  2001-07-03  |  1KB  |  15 lines

  1. \b;Objective
  2. Move toward the spiders that are out of shooting range.
  3.  
  4. \t;Program
  5. The program will look like the previous one, but before you shoot, use the instruction \c;\l;move\u cbot\move;();\n; in order to get close enough.
  6.  
  7. The question is just how many meters the bot must move. The instruction \c;\l;distance\u cbot\dist;( , )\n; calculates the distance between two positions. In this case, we need to know the distance between the bot and the target. The position of the target is given by \c;item.position\n;, the position of the bot is give by \c;position\n;. The distance between the bot and the target is given by \c;\l;distance\u cbot\dist;(position, item.position)\n;. The range of a fireball cannon is 40 meters. In order to get close enough, the bot must move forward \c;\l;distance\u cbot\dist;(position, item.position)-40\n; meters. The following line will do this:
  8. \c;
  9. \s;    \l;move\u cbot\move;(\l;distance\u cbot\dist;(position, item.position)-40);
  10. \n;
  11. Just insert this line into the program before the instruction \c;fire(1);\n;, and the bot will start to move.
  12.  
  13. \t;See also
  14. \l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.
  15.