Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


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

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