Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


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

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