home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / C / DrawLine.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-16  |  1.4 KB  |  71 lines

  1.  
  2. #include <proto/games.h>
  3. #include <proto/exec.h>
  4.  
  5. #define AMT_PLANES 1
  6.  
  7. struct GMSBase *GMSBase;
  8. extern struct ExecBase *SysBase;
  9.  
  10. UWORD Palette[] = 
  11. {
  12.     0x0000,0x08ff
  13. };
  14.  
  15. struct GameScreen *GameScreen;
  16.  
  17. /*=========================================================================*/
  18.  
  19. void main(void)
  20. {
  21.   ULONG mousestat;
  22.   int sx,sy,ex,ey;
  23.  
  24.   sx = 50;
  25.   sy = 50;
  26.   ex = 200;
  27.   ey = 100;
  28.  
  29.   if (GMSBase = (struct GMSBase *) OpenLibrary("games.library",0))
  30.   {
  31.     SetUserPrefs(0);
  32.     if (AllocBlitter() == NULL)
  33.     {
  34.      if (GameScreen = AddScreenTags(TAGS,NULL,
  35.         GSA_Planes,AMT_PLANES,
  36.         GSA_Palette,Palette,
  37.         GSA_ScrMode,HIRES|COL12BIT,
  38.         GSA_ScrWidth,640,
  39.         GSA_ScrHeight,256,
  40.         TAGEND)) {
  41.  
  42.         ShowScreen(GameScreen);
  43.  
  44.         do
  45.         {
  46.           ClrScreen(GameScreen,BUFFER1);
  47.  
  48.           mousestat = ReadMouse(JPORT1);
  49.           if (mousestat & MB_LMB) {
  50.             sx += GetX(mousestat);
  51.             sy += GetY(mousestat);
  52.           }
  53.           else {
  54.             ex += GetX(mousestat);
  55.             ey += GetY(mousestat);
  56.           }
  57.           DrawLine(GameScreen,BUFFER1,sx,sy,ex,ey,1);
  58.           WaitSVBL();
  59.         } while (!(mousestat & MB_RMB));
  60.  
  61.         DeleteScreen(GameScreen);
  62.       }
  63.       FreeBlitter();
  64.     }
  65.     CloseLibrary((struct Library *)GMSBase);
  66.   }
  67. }
  68.  
  69. /*=========================================================================*/
  70.  
  71.