home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / VTREK.ZIP / PLOT.C < prev    next >
Text File  |  1989-12-26  |  6KB  |  281 lines

  1. /* plot.c -- plot routines for visual star trek */
  2.  
  3. #include "vtrek.h"
  4.  
  5. /* replot screen */
  6. replot()
  7. {
  8.     cls();
  9.     plt_stat(ALL);
  10.     plt_srs(ALL);
  11.     plt_dam(ALL);
  12.     plt_gal(ALL);
  13.     moveyx(12, 56);
  14.     printf("READOUT");
  15.     moveyx(13, 56);
  16.     printf("-------");
  17.     plt_num(ALL);
  18. }
  19.  
  20. /* plot status (upper left) */
  21. plt_stat(op, item)
  22. int op, item;
  23. {
  24.     static char *text[9] = {
  25.         "      Status", "      ------", "Stardate     :",
  26.         "Condition    :", "Quadrant     :", "Sector       :",
  27.         "Energy       :", "Photon torps :", "Shields      :"
  28.     };
  29.     static char *ctext[4] = {
  30.         "Green", "Yellow", "Red", "Docked"
  31.     };
  32.     int i, high, low;
  33.  
  34.     if (op & TEXT)
  35.         for (i = 0; i < 9; i++) {
  36.         moveyx(i + 2, 1);
  37.         printf("%s", text[i]);
  38.         }
  39.  
  40.     if (op & (INFO | ELEMENT)) {
  41.         if (op & INFO) {
  42.         low = STARDATE;
  43.         high = SHIELDS;
  44.         }
  45.         else {
  46.         low = item;
  47.         high = item;
  48.         }
  49.  
  50.         for (i = low; i <= high; i++) {
  51.         switch (i) {
  52.         case STARDATE :
  53.             moveyx(4, 16);
  54.             printf("%-.1f", stardate);
  55.             break;
  56.         case CONDITION :
  57.             moveyx(5, 16);
  58.             printf("%-6s", ctext[condition]);
  59.             break;
  60.         case QUADRANT :
  61.             moveyx(6, 16);
  62.             printf("[%d,%d]", xquad + 1, yquad + 1);
  63.             break;
  64.         case SECTOR :
  65.             moveyx(7, 16);
  66.             printf("[%d,%d]", xsect + 1, ysect + 1);
  67.             break;
  68.         case ENERGY :
  69.             moveyx(8, 16);
  70.             printf("%-4d", energy);
  71.             break;
  72.         case TORPS :
  73.             moveyx(9, 16);
  74.             printf("%-2d", torps);
  75.             break;
  76.         case SHIELDS :
  77.             moveyx(10, 16);
  78.             printf("%-4d", shields);
  79.             break;
  80.         }
  81.         }
  82.     }
  83. }
  84.  
  85. /* plot short range scan */
  86. plt_srs(op, xs, ys)
  87. int op, xs, ys;
  88. {
  89.     static char *htext = "-1--2--3--4--5--6--7--8-";
  90.     static char *stext[6] = {
  91.         "   ", "<K>", "<S>", " * ", "???", " + "
  92.     };
  93.     int i, j;
  94.  
  95.     if (op & TEXT) {
  96.         moveyx(1, 28);
  97.         printf("%s", htext);
  98.         for (i = 1; i < 9; i++) {
  99.         moveyx(i + 1, 27);
  100.         printf("%d", i);
  101.         moveyx(i + 1, 52);
  102.         printf("%d", i);
  103.         }
  104.         moveyx(10, 28);
  105.         printf("%s", htext);
  106.     }
  107.  
  108.     strcpy(stext[PLAYER], playership);
  109.  
  110.     if (op & INFO) {
  111.         for (i = 0; i < 8; i++) {
  112.         moveyx(i + 2, 28);
  113.         for (j = 0; j < 8; j++)
  114.             printf("%s", stext[(damage[SRS] <= 0) ? EMPTY : quadrant[j][i]]);
  115.         }
  116.     }
  117.     else if (op & ELEMENT) {
  118.         moveyx(ys + 2, 28 + 3 * xs);
  119.         printf("%s", stext[(damage[SRS] <= 0) ? EMPTY : quadrant[xs][ys]]);
  120.     }
  121. }
  122.  
  123. /* plot damage info */
  124. plt_dam(op, item)
  125. int op, item;
  126. {
  127.     static char *text[10] = {
  128.         "    Damage Report", "    -------------",
  129.         "Warp engines    :", "S.R. sensors    :", "L.R. sensors    :",
  130.         "Phaser control  :", "Damage control  :", "Defense control :",
  131.         "Computer        :", "Photon tubes    :"
  132.     };
  133.     int i;
  134.  
  135.     if (op & TEXT)
  136.         for (i = 0; i < 10; i++) {
  137.         moveyx(i + 1, 56);
  138.         printf("%s", text[i]);
  139.         }
  140.  
  141.     if (op & INFO)
  142.         for (i = 0; i < 8; i++) {
  143.         moveyx(i + 3, 74);
  144.         if (damage[DAMAGE] <= 0)
  145.             printf("    ");
  146.         else
  147.             printf("%4d", damage[i]);
  148.         }
  149.     else if (op & ELEMENT) {
  150.         moveyx(item + 3, 74);
  151.         if (damage[DAMAGE] <= 0)
  152.         printf("    ");
  153.         else
  154.         printf("%4d", damage[item]);
  155.     }
  156. }
  157.  
  158. /* plot galaxy map */
  159. plt_gal(op, xq, yq)
  160. int op, xq, yq;
  161. {
  162.     static char *htext = "-1- -2- -3- -4- -5- -6- -7- -8-";
  163.     int i, j, fedquad;
  164.  
  165.     if (op & TEXT) {
  166.         moveyx(13, 3);
  167.         printf("%s", htext);
  168.         for (i = 1; i < 9; i++) {
  169.         moveyx(i + 13, 1);
  170.         printf("%d|", i);
  171.         for (j = 0; j < 7; j++) {
  172.             moveyx(i + 13, 6 + (j << 2));
  173.             putch('|');
  174.         }
  175.         moveyx(i + 13, 34);
  176.         printf("|%d", i);
  177.         }
  178.         moveyx(22, 3);
  179.         printf("%s", htext);
  180.     }
  181.  
  182.     if (op & INFO) {
  183.         for (i = 0; i < 8; i++)
  184.         for (j = 0; j < 8; j++) {
  185.             moveyx(i + 14, 3 + (j << 2));
  186.             if (damage[COMPUTER] <= 0 || !galaxy[j][i].known)
  187.             printf("   ");
  188.             else {
  189.             if ( galaxy[j][i].nkling > 0 )
  190.                 printf("%01d",galaxy[j][i].nkling );
  191.             else
  192.                 printf("%s"," ");
  193.             if ( galaxy[j][i].nbase > 0 )
  194.                 printf("%s%01d", "B", galaxy[j][i].nstar);
  195.             else
  196.                 printf("%s%01d", " ", galaxy[j][i].nstar);
  197.             }
  198.         }
  199.         moveyx(yquad + 14, 2 + (xquad << 2));
  200.         putch('[');
  201.         moveyx(yquad + 14, 6 + (xquad << 2));
  202.         putch(']');
  203.     }
  204.     else if (op & ELEMENT) {
  205.         moveyx(yq + 14, 2 + (xq << 2));
  206.         fedquad = (xq == xquad && yq == yquad);
  207.         putch(fedquad ? '[' : '|');
  208.         if (damage[COMPUTER] <= 0)
  209.         printf("   ");
  210.         else {
  211.         if ( galaxy[xq][yq].nkling > 0 )
  212.             printf("%01d",galaxy[xq][yq].nkling );
  213.         else
  214.             printf("%s"," ");
  215.         if ( galaxy[xq][yq].nbase > 0 )
  216.             printf("%s%01d", "B", galaxy[xq][yq].nstar);
  217.         else
  218.             printf("%s%01d", " ", galaxy[xq][yq].nstar);
  219.         }
  220.         putch(fedquad ? ']' : '|');
  221.     }
  222. }
  223.  
  224. /* plot number of star bases & klingons */
  225. plt_num(op)
  226. int op;
  227. {
  228.     float kf;
  229.  
  230.     if (op & TEXT) {
  231.         moveyx(23, 3);
  232.         printf("Base stars = ");
  233.         moveyx(23, 19);
  234.         printf("Klingons = ");
  235.         moveyx(24, 10);
  236.         printf("Kill Factor = ");
  237.     }
  238.  
  239.     if (op & INFO) {
  240.         moveyx(23, 15);
  241.         printf(" %d", numbases);
  242.         moveyx(23, 30);
  243.         printf(" %d/%d  ", numkling, begkling);
  244.         moveyx(24, 24);
  245.         if (begdate != stardate)
  246.         kf = (begkling - numkling) / (stardate - begdate);
  247.         else
  248.         kf = 0.0;
  249.         printf("%5.3f  ", kf);
  250.     }
  251. }
  252.  
  253. /* change readout */
  254. readout(op, str)
  255. int op;
  256. char *str;
  257. {
  258.     int i;
  259.  
  260.     switch (op) {
  261.  
  262.     case CLEAR :        /* clear readout */
  263.  
  264.         for (i = 14; i <= 13 + rolines; i++) {
  265.         moveyx(i, 38);
  266.         ceol();
  267.         }
  268.  
  269.         rolines = 0;
  270.         break;
  271.  
  272.     case ADDLINE :        /* add line to readout */
  273.         if (rolines >= 10)
  274.         readout(CLEAR, NULL);
  275.         moveyx(14 + rolines, 38);
  276.         printf("%-.44s", str);
  277.         rolines++;
  278.         break;
  279.     }
  280. }
  281.