home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / WGT_TC21.ZIP / INVADE3.C < prev    next >
C/C++ Source or Header  |  1992-07-17  |  2KB  |  107 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. #include <alloc.h>
  6. #include <ctype.h>          // for upper case conversion
  7. #include "c:\tc\wgt\wgt.h"
  8. #include "c:\tc\wgt\spr.h"
  9.  
  10. block title;
  11.  
  12. color palette[256];
  13. block sprites[201];
  14. int x,y,i;
  15. char k;                        // keyboard input
  16. int shoot;                    // keep track of shots fired
  17.  
  18.  
  19. // sprites numbers (So you don't get confused)
  20. // 1    = spaceship
  21. // 2    = missile fired
  22.  
  23.  
  24. void looper();
  25. extern spclip;
  26.  
  27. void main(void)
  28. {
  29. printf("WordUp Graphics Toolkit Example Program\n\n");
  30. printf("This program is meant to show off what the\n");
  31. printf("WGT Library can do, and is not meant as a\n");
  32. printf("complete shareware or public domain game.\n");
  33. printf("Please remember this while playing the game.\n\n");
  34. printf("Press q during the game to quit...\n\n\n");
  35.  
  36.  
  37. i=minit();
  38. if (i==0)
  39.    {
  40.    printf("Mouse not detected.  You need a mouse for this example program\n");
  41.    printf("Press any key\n");
  42.    getch();
  43.    exit(1);
  44.    }
  45. else printf("Mouse with %i buttons detected.\n",i);
  46. printf("Press any key\n");
  47. getch();
  48.  
  49. vga256();
  50. title=wloadpak("c:\\tc\\wgt\\invade.pak");
  51. wloadsprites(&palette,"c:\\tc\\wgt\\invader.spr",sprites);
  52. initspr();
  53. spon=2;                        // two sprites on now
  54.  
  55. wsetscreen(spritescreen);
  56.  
  57. wputblock(0,0,title,0);
  58. wcopyscreen(0,0,319,199,spritescreen,0,0,NULL);
  59.  
  60. getch();
  61.  
  62. wsetcolor(0);
  63. wbar(0,0,319,140);
  64. wcopyscreen(0,0,319,199,spritescreen,0,0,NULL);
  65.  
  66. spriteon(1,160,148,1);
  67. msetbounds(0,148,319,148);
  68.  
  69. do {
  70. looper();
  71. } while (k !='Q');
  72.  
  73. msetbounds(0,0,319,199);
  74. textmode(C80);
  75. }
  76.  
  77.  
  78. void looper(void)
  79. {
  80. erasespr();
  81.  
  82. mread();
  83. s[1].x=mx;
  84. s[1].y=my;
  85.  
  86. if (but==1)                // if you pressed the left button
  87.   {
  88.     if (shoot==0)            // not shooting then
  89.       {
  90.       spriteon(2,s[1].x+3,s[1].y,2);    // turn on the missile sprite
  91.       movey(2,"(-2,200,0)");          // make it move up
  92.       moveyon(2);            // turn the movement on
  93.       shoot=1;
  94.       }
  95.   }
  96.  
  97.  
  98. if (s[2].y<-10)
  99.   shoot=0;
  100.  
  101. if (kbhit())
  102.    k=toupper(getch());            // convert to uppercase letter
  103.  
  104. drawspr();
  105. }
  106.  
  107.