Advertisement
mixster

Untitled

Nov 15th, 2010
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.14 KB | None | 0 0
  1. program Meh;
  2. var
  3.   frmMain: TForm;
  4.   imgBoard: TImage;
  5.  
  6. const
  7.   debug = True;
  8.  
  9. procedure Write(v: TVariantArray);
  10. var
  11.   i: Integer;
  12.   s: string;
  13. begin
  14.   if debug <> True then
  15.     exit;
  16.   if High(v) < 0 then
  17.     exit;
  18.   for i := 0 to High(v) do
  19.     s := s + v[i];
  20.   Writeln(s);
  21. end;
  22.  
  23. procedure DrawHexagons(var img: TImage; wl, hl: Integer);
  24. var
  25.   a, b, t, bg, ws, hs: Integer;
  26.   p: TPointArray;
  27.   tmp: TCanvas;
  28. begin
  29.   ws := (img.Width - 1) / wl;
  30.   hs := (img.Height - 1) / hl;
  31.   bg := BitmapFromString(img.Width, img.Height, '');
  32.   t := BitmapFromString(ws, hs, '');
  33.   tmp := GetBitmapCanvas(t);
  34.   FastDrawClear(t, clWhite);
  35.   FastDrawClear(bg, clWhite);
  36.  
  37.   with tmp do
  38.   begin
  39.     Pen.Color := clBlack;
  40.     Brush.Color := clWhite;
  41.     SetLength(p, 7);
  42.     p[0].x := 0;
  43.     p[0].y := hs / 4;
  44.     p[1].x := 0;
  45.     p[1].y := (hs * 2) / 4;
  46.     p[2].x := ws / 2;
  47.     p[2].y := (hs * 3) / 4;
  48.     p[3].x := ws;
  49.     p[3].y := (hs * 2) / 4;
  50.     p[4].x := ws;
  51.     p[4].y := hs / 4;
  52.     p[5].x := ws / 2;
  53.     p[5].y := 0;
  54.     p[6].x := 0;
  55.     p[6].y := hs / 4;
  56.     Polygon(p);
  57.   end;
  58.  
  59.   SetTransparentColor(t, clWhite);
  60.  
  61.   for b := 0 to hl - 1 do
  62.     for a := 0 to wl - 1 do
  63.       FastDrawTransparent(a * ws, b * hs, t, bg);
  64.   for b := 0 to hl - 2 do
  65.     for a := 0 to wl - 1 do
  66.       FastDrawTransparent((a * ws) + (ws / 2), (b * hs) + (hs / 2), t, bg);
  67.  
  68.   tmp := GetBitmapCanvas(bg);
  69.   SafeCopyCanvas(tmp, img.Canvas, 0, 0, img.Width, img.Height, 0, 0, img.Width, img.Height);
  70. end;
  71.  
  72.  
  73. procedure SetupForm;
  74. begin
  75.   frmMain := CreateForm;
  76.   with frmMain do
  77.   begin
  78.     ClientWidth := 600;
  79.     ClientHeight := 500;
  80.     Position:= poScreenCenter;
  81.     Caption := 'Strategy Game by mixster';
  82.   end;
  83.  
  84.   imgBoard := TImage.Create(frmMain);
  85.   with imgBoard do
  86.   begin
  87.     Parent := frmMain;
  88.     Width := 501;
  89.     Height := 401
  90.     Left := 50;
  91.     Top := 50;
  92.     DrawHexagons(imgBoard, 2, 2);
  93.   end;
  94.  
  95.   frmMain.ShowModal;
  96. end;
  97.  
  98. procedure LaunchForm;
  99. var
  100.   v: TVariantArray;
  101. begin
  102.   ThreadSafeCall('SetupForm', v);
  103. end;
  104.  
  105. begin
  106.   Write(['Begin']);
  107.   LaunchForm;
  108.   Write(['End']);
  109. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement