home *** CD-ROM | disk | FTP | other *** search
/ Harvey Norman Games / HN.iso / BOARD / G_O_LIFE.ZIP / AIDS.PAS next >
Pascal/Delphi Source File  |  1994-10-24  |  7KB  |  169 lines

  1. (**************************************************************************\
  2. |                                                                          |
  3. |This unit contains alot of the graphic procedures I use. It also contains |
  4. |a pause procedure.                                                        |
  5. |                                            Zaskoda                       |
  6. \**************************************************************************)
  7.  
  8. Unit Aids;
  9.  
  10. Interface
  11.  
  12. Uses Crt,Graph;
  13.  
  14. Procedure TxtOut(Txt:String;X,Y,Txtcol,Shade,Light:Word);
  15.           {This procedure writes text to a graphic screen in a
  16.            3D effect. It's just for looks.}
  17. Procedure Box3D(X1,Y1,X2,Y2,Light,Shade:Word);
  18.           {This procedure draws a 3D rectangle. It's used in
  19.            various places.}
  20. Procedure Pause;
  21.           {Simple pause procedure.}
  22. Procedure BlankForm(X,Y:integer);
  23.           {Clears a graphic block to display a square that does
  24.            not contain a life form}
  25. Procedure LifeForm(X,Y:integer);
  26.           {This procedure draws a creature in a square to represent
  27.            life.}
  28. Procedure TitleScreen;
  29.           {Just a simple title screen to tell what the program is
  30.            and who wrote it.}
  31. Procedure MenuScreen(Prtr,Death:Boolean;GenLoop:Word);
  32.           {This draws the basic Main Menu of the program.}
  33. Procedure DrawGrid;
  34.           {This simpley draws the grid on wich the LifeForms are
  35.            represented graphically}
  36.  
  37. Implementation
  38.  
  39. Procedure TxtOut(Txt:String;X,Y,Txtcol,Shade,Light:Word);
  40.  Begin
  41.   SetColor(Light);                 {Pretty simple, first it draws the     }
  42.   outtextxy(X-1,Y-1,Txt);          {highlighted protion of the text, next }
  43.   outtextxy(X,Y-1,Txt);            {the shaded section, and then the main }
  44.   outtextxy(X-1,Y,Txt);            {color of the text.                    }
  45.   SetColor(Shade);
  46.   outtextxy(X+1,Y+1,Txt);
  47.   outtextxy(X,Y+1,Txt);
  48.   outtextxy(X+1,Y,Txt);
  49.   SetColor(Txtcol);
  50.   outtextxy(X,Y,Txt);
  51.  End;
  52.  
  53. Procedure Box3D(x1,y1,x2,y2,Light,Shade:Word);
  54.  Begin
  55.   SetColor(Light);                 {Just like a rectangle, but it uses    }
  56.   line(x1,y1,x2,y1);               {two colors to produce a 3D effect.    }
  57.   line(x1,y1,x1,y2);
  58.   SetColor(Shade);
  59.   line(x1,y2,x2,y2);
  60.   line(x2,y1,x2,y2);
  61.  End;
  62.  
  63. Procedure Pause;
  64.  Var
  65.   Count:Word;
  66.  Begin
  67.   For Count:=1 to 50 do            {First it clears the keyboard buffer of}
  68.    if keypressed then readkey;     {previous keypresses then it pauses    }
  69.   readkey;                         {until the next key is pressed.        }
  70.  End;
  71.  
  72. Procedure BlankForm(X,Y:integer);  {Just a lightgray box}
  73.  Begin
  74.   SetFillStyle(solidfill,LightGray);
  75.   Bar(x+2,y+2,x+18,y+18);
  76.  End;
  77.  
  78. Procedure LifeForm(X,Y:integer);   {Just a simple little picture, nothing }
  79.  Begin                             {so complicated that it would slow the }
  80.   SetFillStyle(SolidFill,Brown);   {system down to much                   }
  81.   SetColor(Red);
  82.   FillEllipse(x+10,y+10,5,8);
  83.   Setfillstyle(Solidfill,White);
  84.   FillEllipse(x+6,y+5,3,2);
  85.   FillEllipse(x+14,y+5,3,2);
  86.   Putpixel(x+6,y+5,Black);
  87.   PutPixel(x+14,y+5,Black);
  88.   SetColor(LightGray);
  89.   Ellipse(x+10,y+18,5,175,6,7);
  90.   Ellipse(x+10,y+18,5,175,7,6);
  91.  End;
  92.  
  93. Procedure TitleScreen;             {This uses some of the previously      }
  94.  Var                               {defined procedures                    }
  95.   Count:Word;                      {It is fairly simple as well           }
  96.  Begin
  97.   ClearDevice;
  98.   For Count:=0 to 3 do
  99.   Box3D(Count,Count,getmaxx-Count,getmaxy-Count,White,DarkGray);
  100.   Box3D(100,90,getmaxx-100,280,DarkGray,White);
  101.   Box3D(100,10,getmaxx-100,70,DarkGray,White);
  102.   SetTextStyle(10,0,17);
  103.   TxtOut('Life',150,20,LightBlue,Blue,White);
  104.   SetTextStyle(10,0,4);
  105.   TxtOut('The Game of',150,0,LightGray,Blue,White);
  106.   SetTextStyle(10,0,2);
  107.   TxtOut('Written by: Zaskdoda',140,340,LightGray,Blue,White);
  108.   TxtOut('   press any key',140,420,LightGray,DarkGray,White);
  109.   Pause;
  110.   ClearDevice;
  111.  End;
  112.  
  113. Procedure MenuScreen(Prtr,Death:Boolean;GenLoop:Word);
  114.  Var                               {This procedure is called many times by}
  115.   Count:Word;                      {the main program. It just draws the   }
  116.   Dat  :String;                    {graphic portion of the Main Menu.     }
  117.  Begin                             {It also displays the status of the    }
  118.   ClearDevice;                     {printer and death toggles and the     }
  119.   SetBKColor(LightGray);           {number of times the GenLoop will run. }
  120.   For Count:=0 to 3 do
  121.   Box3D(Count,Count,getmaxx-Count,getmaxy-Count,White,DarkGray);
  122.   Box3D(80,90,300,135,DarkGray,White);
  123.   Box3D(80,190,300,235,DarkGray,White);
  124.   Box3D(80,290,300,335,DarkGray,White);
  125.   Box3D(340,90,560,135,DarkGray,White);
  126.   Box3D(340,190,560,235,DarkGray,White);
  127.   Box3D(565,200,620,230,White,DarkGray);
  128.   Box3D(340,290,560,335,DarkGray,White);
  129.   Box3D(565,300,620,330,White,DarkGray);
  130.   Box3D(200,370,440,415,DarkGray,White);
  131.   Box3D(445,380,500,410,White,DarkGray);
  132.   SetTextStyle(2,0,7);
  133.   TxtOut('1',100,100,LightRed,Red,Yellow);
  134.   TxtOut('2',100,200,LightRed,Red,Yellow);
  135.   TxtOut('3',100,300,LightRed,Red,Yellow);
  136.   TxtOut('4',350,100,LightRed,Red,Yellow);
  137.   TxtOut('5',350,200,LightRed,Red,Yellow);
  138.   TxtOut('6',350,300,LightRed,Red,Yellow);
  139.   TxtOut('7',230,380,LightRed,Red,Yellow);
  140.   TxtOut('  Load  File',100,100,LightGray,Blue,White);
  141.   TxtOut('  Save  File',100,200,LightGray,Blue,White);
  142.   TxtOut('  Edit  File',100,300,LightGray,Blue,White);
  143.   TxtOut('  Run   File',350,100,LightGray,Blue,White);
  144.   TxtOut('  Generations',350,200,LightGray,Blue,White);
  145.   TxtOut('  Halt with death?',350,300,LightGray,Blue,White);
  146.   TxtOut('  Printer Toggle',230,380,LightGray,Blue,White);
  147.   Str(GenLoop,Dat);
  148.   TxtOut(Dat,577,205,Green,Black,LightGreen);
  149.   If Death then  TxtOut('On',577,305,Green,Black,LightGreen) else
  150.     TxtOut('Off',575,305,Green,Black,LightGreen);
  151.   If Prtr then  TxtOut('On',457,385,Green,Black,LightGreen) else
  152.     TxtOut('Off',455,385,Green,Black,LightGreen);
  153.   TxtOut('Esc-Exit',275,20,LightGray,DarkGray,White);
  154.  End;
  155.  
  156. Procedure DrawGrid;
  157.  Var                               {Mostly this procedure arranges 3Dboxes}
  158.   Count1,Count2 :Word;             {to design a background to display the }
  159.  Begin                             {status of the life forms              }
  160.   ClearDevice;
  161.   For Count1:=0 to 3 do
  162.   Box3D(Count1,Count1,getmaxx-Count1,getmaxy-Count1,White,DarkGray);
  163.   Box3D(199,39,601,441,White,DarkGray);
  164.   For Count1:=0 to 19 do
  165.   For Count2:=0 to 19 do
  166.    Box3D(201+Count1*20,41+count2*20,219+count1*20,59+count2*20,DarkGray,White);
  167.  End;
  168.  
  169. End.