Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (hide annotations) (download) (as text)
Sun Jul 19 01:35:48 2015 UTC (8 years, 7 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 16155 byte(s)
少し元に戻しました

Subversionの更新を行いました、どうなるんでしょうか
1 yamat0jp 5 unit Unit1;
2 yamat0jp 1
3     interface
4    
5     uses
6 yamat0jp 5 System.SysUtils, System.Types, System.UITypes, System.Classes,
7     System.Variants,
8     FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Menus,
9     System.Math, FMX.Objects, FMX.StdCtrls;
10 yamat0jp 1
11     const
12     Count = 8;
13    
14     type
15 yamat0jp 14 TStoneType = (stNone, stWhite, stBlack, stError, stEffect);
16 yamat0jp 1
17 yamat0jp 14 TEffectData = record
18     X, Y: integer;
19     Left, Top: integer;
20     Stone: TStoneType;
21     end;
22    
23 yamat0jp 3 TGridData = array [0 .. Count - 1] of array [0 .. Count - 1] of TStoneType;
24 yamat0jp 1
25     TPlayer = class
26     private
27     FAuto: Boolean;
28 yamat0jp 4 FStone: TStoneType;
29 yamat0jp 1 public
30     property Auto: Boolean read FAuto write FAuto;
31 yamat0jp 4 property Stone: TStoneType read FStone write FStone;
32 yamat0jp 1 end;
33    
34     TStoneGrid = class
35     private
36     FStrings: TGridData;
37 yamat0jp 7 FBuffer: array [0 .. Count * Count - 4] of TGridData;
38 yamat0jp 1 FTurnNumber: integer;
39     FTurnIndex: integer;
40 yamat0jp 9 FActive: Boolean;
41 yamat0jp 24 FList: TList;
42 yamat0jp 20 FEffectStone: TStoneType;
43 yamat0jp 15 FBool: Boolean;
44 yamat0jp 21 FTerminated: Boolean;
45 yamat0jp 14 FIndex_X: integer;
46     FIndex_Y: integer;
47 yamat0jp 1 function GetStrings(X, Y: integer): TStoneType;
48     procedure SetStrings(X, Y: integer; const Value: TStoneType);
49     procedure SetTurnNumber(const Value: integer);
50     public
51 yamat0jp 14 constructor Create;
52     destructor Destroy; override;
53 yamat0jp 1 procedure Clear;
54 yamat0jp 10 function CalScore(Stone: TStoneType; X, Y: integer): integer;
55     function CanSetStone(Stone: TStoneType; X, Y: integer; Reverse: Boolean;
56 yamat0jp 7 const Visible: Boolean = false): Boolean;
57 yamat0jp 10 function NextStone(Stone: TStoneType): TPoint;
58 yamat0jp 9 procedure Start;
59     procedure Restart;
60     procedure Pause;
61 yamat0jp 14 function ListExecute: Boolean;
62     procedure Paint(Canvas: TCanvas);
63     procedure ImageCount(X, Y: integer);
64 yamat0jp 3 property Strings[X, Y: integer]: TStoneType read GetStrings
65     write SetStrings; default;
66 yamat0jp 1 property TurnNumber: integer read FTurnNumber write SetTurnNumber;
67 yamat0jp 10 property Active: Boolean read FActive;
68 yamat0jp 1 end;
69    
70     TForm1 = class(TForm)
71     Timer1: TTimer;
72     MainMenu1: TMainMenu;
73 yamat0jp 5 MenuItem1: TMenuItem;
74     MenuItem2: TMenuItem;
75     MenuItem3: TMenuItem;
76     MenuItem4: TMenuItem;
77     MenuItem5: TMenuItem;
78     MenuItem6: TMenuItem;
79     MenuItem7: TMenuItem;
80     PaintBox1: TPaintBox;
81 yamat0jp 7 MenuItem8: TMenuItem;
82     MenuItem9: TMenuItem;
83     MenuItem10: TMenuItem;
84     MenuItem11: TMenuItem;
85     MenuItem12: TMenuItem;
86 yamat0jp 14 Timer2: TTimer;
87     Image1: TImage;
88     Image2: TImage;
89     Image3: TImage;
90     Image4: TImage;
91 yamat0jp 15 Image5: TImage;
92 yamat0jp 1 procedure FormCreate(Sender: TObject);
93     procedure FormDestroy(Sender: TObject);
94     procedure Timer1Timer(Sender: TObject);
95     procedure FormResize(Sender: TObject);
96 yamat0jp 5 procedure MenuItem4Click(Sender: TObject);
97     procedure MenuItem2Click(Sender: TObject);
98 yamat0jp 7 procedure PaintBox1Tap(Sender: TObject; const Point: TPointF);
99     procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
100 yamat0jp 5 Shift: TShiftState; X, Y: Single);
101     procedure PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
102     procedure MenuItem6Click(Sender: TObject);
103 yamat0jp 7 procedure PaintBox1Resize(Sender: TObject);
104     procedure MenuItem8Click(Sender: TObject);
105     procedure MenuItem10Click(Sender: TObject);
106     procedure MenuItem11Click(Sender: TObject);
107 yamat0jp 14 procedure Timer2Timer(Sender: TObject);
108 yamat0jp 24 procedure FormDeactivate(Sender: TObject);
109     procedure FormActivate(Sender: TObject);
110 yamat0jp 1 private
111 yamat0jp 5 { Private ���� }
112 yamat0jp 1 StoneGrid: TStoneGrid;
113     Index: TPlayer;
114     Size: integer;
115     procedure CompStone;
116     procedure GameStart;
117     procedure ChangePlayer;
118     public
119 yamat0jp 5 { Public ���� }
120 yamat0jp 1 end;
121    
122     var
123     Player1: TPlayer;
124     Player2: TPlayer;
125    
126     Form1: TForm1;
127    
128     implementation
129    
130 yamat0jp 5 {$R *.fmx}
131 yamat0jp 7 {$R *.Windows.fmx MSWINDOWS}
132 yamat0jp 1 { TStoneGrid }
133    
134 yamat0jp 10 function TStoneGrid.CalScore(Stone: TStoneType; X, Y: integer): integer;
135 yamat0jp 1 var
136     i, j: integer;
137     begin
138 yamat0jp 10 if CanSetStone(Stone, X, Y, true) = true then
139 yamat0jp 1 begin
140 yamat0jp 20 case Stone of
141 yamat0jp 23 stBlack:
142     Stone := stWhite;
143     stWhite:
144     Stone := stBlack;
145     stEffect:
146     Stone := FEffectStone;
147 yamat0jp 20 end;
148 yamat0jp 3 result := 0;
149     for i := 0 to Count - 1 do
150     for j := 0 to Count - 1 do
151 yamat0jp 10 if CanSetStone(Stone, i, j, false) = true then
152 yamat0jp 3 inc(result);
153 yamat0jp 9 FStrings := FBuffer[FTurnIndex];
154 yamat0jp 3 end
155     else
156 yamat0jp 1 begin
157 yamat0jp 9 FStrings := FBuffer[FTurnIndex];
158 yamat0jp 3 result := -1;
159 yamat0jp 1 end;
160     end;
161    
162 yamat0jp 10 function TStoneGrid.CanSetStone(Stone: TStoneType; X, Y: integer;
163 yamat0jp 7 Reverse: Boolean; const Visible: Boolean): Boolean;
164 yamat0jp 1 var
165 yamat0jp 14 i: integer;
166 yamat0jp 4 p: Boolean;
167 yamat0jp 14 q: ^TEffectData;
168 yamat0jp 4 procedure Method(m, n: integer);
169 yamat0jp 3 var
170 yamat0jp 4 s: TStoneType;
171 yamat0jp 15 j, k: integer;
172 yamat0jp 1 begin
173 yamat0jp 4 if p = false then
174     Exit;
175     i := 1;
176 yamat0jp 3 while true do
177 yamat0jp 4 begin
178     s := GetStrings(X + m * i, Y + n * i);
179 yamat0jp 19 if s = stEffect then
180 yamat0jp 23 s := FEffectStone;
181 yamat0jp 4 if (s = stNone) or (s = stError) then
182     break
183 yamat0jp 10 else if s = Stone then
184 yamat0jp 4 if i > 1 then
185     begin
186 yamat0jp 15 if (result = false) and (Reverse = true) then
187     SetStrings(X, Y, Stone);
188 yamat0jp 4 result := true;
189     if Reverse = true then
190 yamat0jp 1 begin
191 yamat0jp 4 for j := 1 to i - 1 do
192 yamat0jp 7 begin
193 yamat0jp 15 Form1.PaintBox1.Repaint;
194 yamat0jp 14 if Visible = true then
195     begin
196 yamat0jp 23 FEffectStone := Stone;
197 yamat0jp 14 New(q);
198     q^.Left := X + m * j;
199     q^.Top := Y + n * j;
200     q^.Stone := Stone;
201     q^.X := 0;
202     q^.Y := 0;
203 yamat0jp 24 FList.Add(q);
204 yamat0jp 14 SetStrings(q^.Left, q^.Top, stEffect);
205 yamat0jp 19 for k := 1 to 100 do
206 yamat0jp 15 begin
207 yamat0jp 19 Sleep(1);
208 yamat0jp 15 Application.ProcessMessages;
209     end;
210 yamat0jp 14 end
211     else
212     SetStrings(X + m * j, Y + n * j, Stone);
213 yamat0jp 7 end;
214 yamat0jp 4 break;
215 yamat0jp 3 end
216     else
217 yamat0jp 1 begin
218 yamat0jp 4 p := false;
219 yamat0jp 3 break;
220 yamat0jp 4 end;
221     end
222     else
223     break
224 yamat0jp 3 else
225 yamat0jp 4 inc(i);
226     end;
227 yamat0jp 3 end;
228    
229     begin
230 yamat0jp 17 result := false;
231 yamat0jp 15 if Visible = true then
232     begin
233     FBool := FActive;
234     FActive := false;
235     end;
236 yamat0jp 14 p := true;
237     if GetStrings(X, Y) = stNone then
238 yamat0jp 9 begin
239 yamat0jp 14 Method(-1, -1);
240     Method(-1, 0);
241     Method(-1, 1);
242     Method(0, -1);
243     Method(0, 1);
244     Method(1, -1);
245     Method(1, 0);
246     Method(1, 1);
247 yamat0jp 9 end;
248 yamat0jp 1 end;
249    
250     procedure TStoneGrid.Clear;
251     var
252     i, j: integer;
253     begin
254 yamat0jp 24 for i := 0 to FList.Count - 1 do
255     Dispose(FList[i]);
256     FList.Clear;
257 yamat0jp 3 for i := 0 to Count - 1 do
258     for j := 0 to Count - 1 do
259     Strings[i, j] := stNone;
260     Strings[3, 3] := stBlack;
261     Strings[4, 4] := stBlack;
262     Strings[4, 3] := stWhite;
263     Strings[3, 4] := stWhite;
264 yamat0jp 7 FTurnNumber := 0;
265     FTurnIndex := 0;
266 yamat0jp 10 FBuffer[0] := FStrings;
267 yamat0jp 1 end;
268    
269 yamat0jp 14 constructor TStoneGrid.Create;
270     begin
271     inherited;
272 yamat0jp 24 FList := TList.Create;
273 yamat0jp 14 end;
274    
275     destructor TStoneGrid.Destroy;
276     var
277     i: integer;
278     begin
279 yamat0jp 24 for i := 0 to FList.Count - 1 do
280     Dispose(FList[i]);
281     FList.Free;
282 yamat0jp 14 inherited;
283     end;
284    
285 yamat0jp 1 function TStoneGrid.GetStrings(X, Y: integer): TStoneType;
286     begin
287 yamat0jp 3 if (X >= 0) and (X < Count) and (Y >= 0) and (Y < Count) then
288 yamat0jp 4 result := FStrings[X, Y]
289 yamat0jp 3 else
290     result := stError;
291 yamat0jp 1 end;
292    
293 yamat0jp 14 procedure TStoneGrid.ImageCount(X, Y: integer);
294     begin
295     FIndex_X := X;
296     FIndex_Y := Y;
297     end;
298    
299     function TStoneGrid.ListExecute: Boolean;
300     var
301     p: ^TEffectData;
302     i: integer;
303     begin
304 yamat0jp 24 if FList.Count = 0 then
305 yamat0jp 14 result := false
306     else
307     begin
308 yamat0jp 24 for i := 0 to FList.Count - 1 do
309 yamat0jp 14 begin
310 yamat0jp 24 p := FList[i];
311 yamat0jp 14 if p^.X < FIndex_X - 1 then
312     p^.X := p^.X + 1
313     else if p^.Y < FIndex_Y - 1 then
314     begin
315     p^.X := 0;
316     p^.Y := p^.Y + 1;
317     end
318     else
319     begin
320     SetStrings(p^.Left, p^.Top, p^.Stone);
321     Dispose(p);
322 yamat0jp 24 FList[i] := nil;
323 yamat0jp 14 end;
324     end;
325 yamat0jp 24 for i := FList.Count - 1 downto 0 do
326     if FList[i] = nil then
327     FList.Delete(i);
328     if FList.Count = 0 then
329 yamat0jp 14 begin
330 yamat0jp 21 if FTerminated = true then
331 yamat0jp 23 FActive := false
332 yamat0jp 21 else
333     FActive := FBool;
334 yamat0jp 14 inc(FTurnIndex);
335     inc(FTurnNumber);
336     FBuffer[FTurnIndex] := FStrings;
337     end;
338     result := true;
339     end;
340     end;
341    
342 yamat0jp 10 function TStoneGrid.NextStone(Stone: TStoneType): TPoint;
343 yamat0jp 1 var
344     i, j, m, n: integer;
345     begin
346 yamat0jp 3 n := -1;
347     for i := 0 to Count - 1 do
348     for j := 0 to Count - 1 do
349 yamat0jp 1 begin
350 yamat0jp 10 m := CalScore(Stone, i, j);
351 yamat0jp 3 if (n = -1) or ((m > -1) and (n > m)) then
352 yamat0jp 1 begin
353 yamat0jp 3 n := m;
354     result := Point(i, j);
355 yamat0jp 1 end;
356     end;
357     if n = -1 then
358 yamat0jp 3 result := Point(-1, -1);
359 yamat0jp 1 end;
360    
361 yamat0jp 14 procedure TStoneGrid.Paint(Canvas: TCanvas);
362     var
363     i: integer;
364     k, m, n: integer;
365     s: TBitmap;
366     p: ^TEffectData;
367     begin
368     m := Form1.Image3.Bitmap.Width;
369     n := Form1.Image3.Bitmap.Height;
370 yamat0jp 15 k := Form1.Size;
371 yamat0jp 24 for i := 0 to FList.Count - 1 do
372 yamat0jp 14 begin
373 yamat0jp 24 p := FList[i];
374 yamat0jp 14 if p^.Stone = stBlack then
375     s := Form1.Image1.Bitmap
376     else
377     s := Form1.Image2.Bitmap;
378     Canvas.DrawBitmap(s, RectF(p^.X * m, p^.Y * n, (p^.X + 1) * m,
379     (p^.Y + 1) * n), RectF(p^.Left * k, p^.Top * k, (p^.Left + 1) * k,
380     (p^.Top + 1) * k), 1);
381     end;
382     end;
383    
384 yamat0jp 9 procedure TStoneGrid.Pause;
385     begin
386 yamat0jp 23 if FActive = true then
387     FActive := false;
388     FTerminated := true;
389 yamat0jp 9 end;
390    
391     procedure TStoneGrid.Restart;
392     begin
393 yamat0jp 21 if FTerminated = true then
394     begin
395     FActive := true;
396     FTurnIndex := FTurnNumber;
397 yamat0jp 23 FTerminated := false;
398 yamat0jp 21 end;
399 yamat0jp 9 end;
400    
401 yamat0jp 1 procedure TStoneGrid.SetStrings(X, Y: integer; const Value: TStoneType);
402     begin
403 yamat0jp 3 if (X >= 0) and (X < Count) and (Y >= 0) and (Y < Count) then
404     FStrings[X, Y] := Value;
405 yamat0jp 1 end;
406    
407     procedure TStoneGrid.SetTurnNumber(const Value: integer);
408     begin
409     if Value > FTurnIndex then
410 yamat0jp 4 FTurnNumber := FTurnIndex
411 yamat0jp 12 else if Value < 0 then
412     FTurnNumber := 0
413 yamat0jp 3 else
414     FTurnNumber := Value;
415     FStrings := FBuffer[FTurnNumber];
416 yamat0jp 1 end;
417    
418 yamat0jp 9 procedure TStoneGrid.Start;
419     begin
420     Clear;
421 yamat0jp 23 FTerminated := false;
422 yamat0jp 9 FActive := true;
423     end;
424    
425 yamat0jp 1 { TForm1 }
426    
427     procedure TForm1.ChangePlayer;
428     var
429     i, j, m, n: integer;
430     s: string;
431     procedure Main;
432     begin
433     if Index = Player1 then
434 yamat0jp 17 begin
435     Index := Player2;
436     s := '������������';
437     end
438 yamat0jp 3 else
439 yamat0jp 17 begin
440 yamat0jp 3 Index := Player1;
441 yamat0jp 17 s := '������������';
442     end;
443 yamat0jp 1 end;
444     function Execute: Boolean;
445     var
446     i, j: integer;
447 yamat0jp 17 m: integer;
448     n: integer;
449 yamat0jp 1 begin
450 yamat0jp 18 for i := 0 to Count - 1 do
451     for j := 0 to Count - 1 do
452     if StoneGrid.CanSetStone(Index.Stone, i, j, false) = true then
453     begin
454     result := true;
455     Exit;
456     end;
457 yamat0jp 3 result := false;
458 yamat0jp 1 end;
459 yamat0jp 3
460 yamat0jp 1 begin
461 yamat0jp 24 Timer1.Enabled:=false;
462 yamat0jp 3 Main;
463 yamat0jp 1 if Execute = false then
464     begin
465 yamat0jp 3 Main;
466 yamat0jp 1 if Execute = false then
467     begin
468 yamat0jp 9 StoneGrid.Pause;
469 yamat0jp 3 m := 0;
470     n := 0;
471     for i := 0 to Count - 1 do
472     for j := 0 to Count - 1 do
473     case StoneGrid[i, j] of
474     stBlack:
475     inc(m);
476     stWhite:
477     inc(n);
478 yamat0jp 1 end;
479 yamat0jp 17 Caption := s;
480 yamat0jp 1 if m > n then
481 yamat0jp 4 s := 'Player1 Win:' + #13#10
482 yamat0jp 3 else if m < n then
483 yamat0jp 4 s := 'Player2 Win:' + #13#10
484 yamat0jp 3 else
485     s := 'Draw:' + #13#10;
486 yamat0jp 7 Showmessage(s + '(Player1) ' + IntToStr(m) + #13#10 + '(Player2) ' +
487     IntToStr(n));
488 yamat0jp 17 end
489     else
490     Caption := s;
491     end
492     else
493     Caption := s;
494 yamat0jp 24 Timer1.Enabled:=true;
495 yamat0jp 1 end;
496    
497     procedure TForm1.CompStone;
498     var
499     s: TPoint;
500     begin
501 yamat0jp 10 s := StoneGrid.NextStone(Index.Stone);
502     StoneGrid.CanSetStone(Index.Stone, s.X, s.Y, true, true);
503 yamat0jp 5 PaintBox1.Repaint;
504 yamat0jp 7 ChangePlayer;
505 yamat0jp 1 end;
506    
507     procedure TForm1.GameStart;
508     begin
509 yamat0jp 24 Timer1.Enabled:=false;
510 yamat0jp 21 Index := Player1;
511 yamat0jp 9 StoneGrid.Start;
512 yamat0jp 5 PaintBox1.Repaint;
513 yamat0jp 17 Caption := '�������n������';
514 yamat0jp 24 Timer1.Enabled:=true;
515 yamat0jp 1 end;
516    
517 yamat0jp 7 procedure TForm1.MenuItem10Click(Sender: TObject);
518     begin
519 yamat0jp 9 StoneGrid.Restart;
520 yamat0jp 7 end;
521    
522     procedure TForm1.MenuItem11Click(Sender: TObject);
523 yamat0jp 17 var
524     i: integer;
525 yamat0jp 7 begin
526     with StoneGrid do
527 yamat0jp 17 begin
528     i := TurnNumber;
529 yamat0jp 7 if Sender = MenuItem11 then
530     TurnNumber := TurnNumber + 1
531     else
532     TurnNumber := TurnNumber - 1;
533 yamat0jp 17 if (i = TurnNumber) then
534     Exit
535     else
536     Pause;
537     end;
538 yamat0jp 14 PaintBox1.Repaint;
539 yamat0jp 12 ChangePlayer;
540 yamat0jp 7 end;
541    
542 yamat0jp 5 procedure TForm1.MenuItem2Click(Sender: TObject);
543 yamat0jp 1 begin
544 yamat0jp 3 GameStart;
545 yamat0jp 1 end;
546    
547 yamat0jp 5 procedure TForm1.MenuItem4Click(Sender: TObject);
548 yamat0jp 1 begin
549 yamat0jp 5 Close;
550 yamat0jp 1 end;
551    
552 yamat0jp 5 procedure TForm1.MenuItem6Click(Sender: TObject);
553     begin
554 yamat0jp 7 Player1.Auto := MenuItem6.IsChecked;
555     Player2.Auto := MenuItem7.IsChecked;
556 yamat0jp 5 end;
557    
558 yamat0jp 7 procedure TForm1.MenuItem8Click(Sender: TObject);
559     begin
560 yamat0jp 9 StoneGrid.Pause;
561 yamat0jp 7 end;
562    
563 yamat0jp 5 procedure TForm1.PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
564 yamat0jp 1 var
565     i, j: integer;
566     begin
567 yamat0jp 18 if StoneGrid.Active = false then
568     StoneGrid.Paint(Canvas);
569 yamat0jp 17 for i := 0 to Count - 1 do
570 yamat0jp 1 begin
571 yamat0jp 17 for j := 0 to Count - 1 do
572 yamat0jp 1 begin
573 yamat0jp 3 case StoneGrid.Strings[i, j] of
574     stWhite:
575 yamat0jp 14 Canvas.DrawBitmap(Image4.Bitmap, RectF(0, 0, Image4.Bitmap.Width,
576     Image4.Bitmap.Height), RectF(i * Size, j * Size, (i + 1) * Size,
577 yamat0jp 7 (j + 1) * Size), 1);
578 yamat0jp 3 stBlack:
579 yamat0jp 14 Canvas.DrawBitmap(Image3.Bitmap, RectF(0, 0, Image3.Bitmap.Width,
580     Image3.Bitmap.Height), RectF(i * Size, j * Size, (i + 1) * Size,
581     (j + 1) * Size), 1);
582 yamat0jp 15 stEffect:
583     continue;
584 yamat0jp 14 else
585 yamat0jp 15 Canvas.DrawBitmap(Image5.Bitmap, RectF(0, 0, Image5.Bitmap.Width,
586     Image5.Bitmap.Height), RectF(i * Size, j * Size, (i + 1) * Size,
587     (j + 1) * Size), 1);
588 yamat0jp 1 end;
589 yamat0jp 15 Canvas.DrawLine(PointF(0, j * Size), PointF(Count * Size, j * Size), 1);
590 yamat0jp 1 end;
591 yamat0jp 15 Canvas.DrawLine(PointF(i * Size, 0), PointF(i * Size, Size * Count), 1);
592 yamat0jp 1 end;
593 yamat0jp 17 Canvas.DrawLine(PointF(Count * Size, 0),
594     PointF(Count * Size, Count * Size), 1);
595     Canvas.DrawLine(PointF(0, Count * Size),
596     PointF(Count * Size, Count * Size), 1);
597 yamat0jp 1 end;
598    
599 yamat0jp 7 procedure TForm1.PaintBox1Resize(Sender: TObject);
600     begin
601     Size := Min(ClientWidth, ClientHeight) div Count;
602     end;
603    
604 yamat0jp 24 procedure TForm1.FormActivate(Sender: TObject);
605     begin
606     Timer1.Enabled := true;
607     end;
608    
609 yamat0jp 5 procedure TForm1.FormCreate(Sender: TObject);
610 yamat0jp 1 begin
611 yamat0jp 5 StoneGrid := TStoneGrid.Create;
612 yamat0jp 14 StoneGrid.ImageCount(Form1.Image1.Bitmap.Width div Form1.Image3.Bitmap.Width,
613     Form1.Image1.Bitmap.Height div Form1.Image3.Bitmap.Height);
614 yamat0jp 5 Player1 := TPlayer.Create;
615     Player2 := TPlayer.Create;
616     Player1.Stone := stBlack;
617     Player2.Stone := stWhite;
618     Player2.Auto := true;
619     with PaintBox1.Canvas do
620 yamat0jp 1 begin
621 yamat0jp 5 StrokeDash := TStrokeDash.Solid;
622     Stroke.Color := TAlphaColors.Black;
623     StrokeThickness := 3;
624 yamat0jp 1 end;
625 yamat0jp 7 PaintBox1Resize(Sender);
626 yamat0jp 5 GameStart;
627 yamat0jp 1 end;
628    
629 yamat0jp 24 procedure TForm1.FormDeactivate(Sender: TObject);
630     begin
631     Timer1.Enabled := false;
632     end;
633    
634 yamat0jp 5 procedure TForm1.FormDestroy(Sender: TObject);
635     begin
636     StoneGrid.Free;
637     Player1.Free;
638     Player2.Free;
639     end;
640    
641 yamat0jp 7 procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
642 yamat0jp 5 Shift: TShiftState; X, Y: Single);
643     begin
644 yamat0jp 7 PaintBox1Tap(Sender, PointF(X, Y));
645 yamat0jp 5 end;
646    
647 yamat0jp 1 procedure TForm1.Timer1Timer(Sender: TObject);
648     begin
649 yamat0jp 10 if (StoneGrid.Active = true) and (Index.Auto = true) then
650 yamat0jp 3 CompStone;
651 yamat0jp 1 end;
652    
653 yamat0jp 14 procedure TForm1.Timer2Timer(Sender: TObject);
654     begin
655 yamat0jp 23 if (StoneGrid.Active = false) and (StoneGrid.ListExecute = true) then
656 yamat0jp 14 PaintBox1.Repaint;
657     end;
658    
659 yamat0jp 1 procedure TForm1.FormResize(Sender: TObject);
660     begin
661 yamat0jp 3 Size := Min(ClientWidth, ClientHeight) div Count;
662 yamat0jp 5 PaintTo(Canvas);
663 yamat0jp 1 end;
664    
665 yamat0jp 7 procedure TForm1.PaintBox1Tap(Sender: TObject; const Point: TPointF);
666 yamat0jp 1 begin
667 yamat0jp 11 if Index.Auto = false then
668     begin
669 yamat0jp 10 MenuItem10Click(Sender);
670     if StoneGrid.CanSetStone(Index.Stone, Floor(Point.X / Size),
671 yamat0jp 7 Floor(Point.Y / Size), true, true) = true then
672 yamat0jp 5 begin
673     PaintBox1.Repaint;
674 yamat0jp 7 ChangePlayer;
675 yamat0jp 5 end;
676     end;
677 yamat0jp 1 end;
678    
679     end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26