home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1996 #3 / AmigaPlus_CD-ROM-EXTRA_Nr.3.bin / aminet-spiele / brettspiele / migamind / layout.c < prev    next >
C/C++ Source or Header  |  1990-08-11  |  3KB  |  125 lines

  1. /*****************************************************************************
  2.  
  3.                 Paint.c
  4.             Some GFX-functions, obviously.
  5.                                 1-5-90
  6.                                  Ekke
  7. *****************************************************************************/
  8.  
  9. #include <exec/types.h>
  10. #include <graphics/gfx.h>
  11. #include <graphics/gfxmacros.h>
  12. #include <proto/all.h>
  13. #include "Gads.h"
  14. #include "MM_Proto.h"
  15.  
  16. /****************************************************************************/
  17. void Line(struct RastPort *rp,WORD x1,WORD y1,WORD x2,WORD y2)
  18. {
  19.     Move(rp,x1,y1);
  20.     Draw(rp,x2,y2);
  21. }
  22.  
  23. /****************************************************************************/
  24. void PaintLines(struct RastPort *rp)
  25. {
  26. int i;
  27. WORD y;
  28. WORD l[4] = { 0,1,96,97 };
  29. WORD m[4] = { 18,19,78,79 };
  30.  
  31.     SetAPen(rp,1);
  32. /* horizontaal */
  33.     Line(rp,0,0,97,0);
  34.     for (i=0,y=16; i<11; i++,y+=12) Line(rp,0,y,97,y);
  35.     Line(rp,0,152,97,152);
  36. /* vertikaal */
  37.     for (i=0; i<4; i++) Line(rp,l[i],0,l[i],152);    
  38.     for (i=0; i<4; i++) Line(rp,m[i],16,m[i],136);    
  39. }
  40.  
  41. /****************************************************************************/
  42. void HRBorder(struct RastPort *rp,WORD x1,WORD y1,WORD x2,WORD y2)
  43. {
  44.     Move(rp,x1,y1);        /*                */
  45.     Draw(rp,x1,y2);        /*    |        |    */
  46.     Draw(rp,x2-1,y2);    /*    |        |    */
  47.     Draw(rp,x2-1,y1+1);    /*    |_______________|    */
  48.  
  49.     Move(rp,x1+1,y2-1);    /*      _______________    */
  50.     Draw(rp,x1+1,y1);    /*     |         |    */
  51.     Draw(rp,x2,y1);        /*     |         |    */
  52.     Draw(rp,x2,y2);        /*     |         |    */
  53. }
  54.  
  55. /****************************************************************************/
  56. void PaintBorders(struct RastPort *rp)
  57. {
  58.     SetAPen(rp,3);
  59.     HRBorder(rp,4,2,93,14);
  60.     HRBorder(rp,4,138,47,150);
  61.     HRBorder(rp,50,138,93,150);
  62. }
  63.  
  64. /****************************************************************************/
  65. void PaintGads(struct RastPort *rp)
  66. {
  67. int i,j;
  68. WORD x,y;
  69.  
  70.     for (i=0; i<6; i++) DrawGad(rp,0,i,i,0);
  71.     SetAPen(rp,2);
  72.     for (i=0; i<4; i++)
  73.     {   for (j=1; j<11; j++)
  74.         {    x = GadPosX(j,i);
  75.         y = GadPosY(j);
  76.         RectFill(rp,x,y,x+GAD_W,y+GAD_H);
  77.     }   }
  78.     DrawSysGad(rp,QUIT,0,0);
  79.     DrawSysGad(rp,SHOW,0,0);
  80. }
  81.  
  82. /****************************************************************************/
  83. void LayOut(struct RastPort *rp)
  84. {
  85.     SetRast(rp,0);
  86.     BNDRYOFF(rp);
  87.     SetDrMd(rp,JAM1);
  88.  
  89.     PaintLines(rp);
  90.     PaintBorders(rp);
  91.     PaintGads(rp);
  92. }
  93.  
  94. /****************************************************************************/
  95. void Block(struct RastPort *rp,WORD x,WORD y)
  96. {
  97.     Move(rp,x,y);
  98.     Draw(rp,x+2,y);
  99.     Move(rp,x,y+1);
  100.     Draw(rp,x+2,y+1);
  101. }
  102.  
  103. /****************************************************************************/
  104. void PaintWright(struct RastPort *rp,int turn,int colors,int positions)
  105. {
  106. WORD y[2] = {1,6}, x[4] = {5,12,83,90}, ypos;
  107.  
  108.     ypos = GadPosY(turn);
  109.  
  110.     SetAPen(rp,2);    
  111.     if (colors > 3) Block(rp,x[3],(WORD)(y[1]+ypos));
  112.     if (colors > 2) Block(rp,x[2],(WORD)(y[1]+ypos));
  113.     if (colors > 1) Block(rp,x[3],(WORD)(y[0]+ypos));
  114.     if (colors > 0) Block(rp,x[2],(WORD)(y[0]+ypos));
  115.  
  116.     SetAPen(rp,3);
  117.     if (positions > 3) Block(rp,x[1],(WORD)(y[1]+ypos));
  118.     if (positions > 2) Block(rp,x[0],(WORD)(y[1]+ypos));
  119.     if (positions > 1) Block(rp,x[1],(WORD)(y[0]+ypos));
  120.     if (positions > 0) Block(rp,x[0],(WORD)(y[0]+ypos));
  121. }
  122.  
  123.  
  124.  
  125.