Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations) (download) (as text)
Sat Jul 18 23:47:44 2015 UTC (8 years, 7 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 15763 byte(s)
結局対応を試みてきたバグは改善できませんでした

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

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