Develop and Download Open Source Software

Browse Subversion Repository

Diff of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by yamat0jp, Fri Oct 9 14:55:49 2015 UTC revision 2 by yamat0jp, Sat Oct 10 00:23:06 2015 UTC
# Line 39  type Line 39  type
39      FAY: integer;      FAY: integer;
40      FSpeed: integer;      FSpeed: integer;
41      FVisible: Boolean;      FVisible: Boolean;
42        FPattern: integer;
43    protected    protected
44      FFlightData: TMapData;      FFlightData: TMapData;
45      procedure Search;      procedure Search;
46      procedure HardSearch;      function HardSearch: Boolean;
47        procedure Buffer;
48      property AX: integer read FAX write FAX;      property AX: integer read FAX write FAX;
49      property AY: integer read FAY write FAY;      property AY: integer read FAY write FAY;
50      property Index: integer read FIndex write FIndex;      property Index: integer read FIndex write FIndex;
51        property Pattern: integer read FPattern write FPattern;
52    
53      const
54        Kind = 3;
55        Span = 10;
56    public    public
57      constructor Create;      constructor Create;
58      procedure Clear;      procedure Clear;
# Line 84  implementation Line 91  implementation
91  {$R *.fmx}  {$R *.fmx}
92  { TEnemy }  { TEnemy }
93    
94  procedure TEnemy.Clear;  procedure TEnemy.Buffer;
 begin  
   Index := 1;  
   HardSearch;  
   X := AX * Size;  
   Y := AY * Size;  
   Index := 2;  
   Search;  
 end;  
   
 constructor TEnemy.Create;  
95  const  const
96    AData: TMapData = (    AData: array [0 .. Kind - 1] of TMapData = ((
97    
98      (0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),      (0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
99      (0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0),      (0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0),
# Line 117  const Line 114  const
114      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
115      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
116      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
117      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), (
118    
119        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
120        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
121        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
122        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
123        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
124        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
125        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
126        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
127        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
128        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
129        (1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18),
130        (0, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 16, 0, 0),
131        (0, 0, 0, 0, 5, 6, 0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 0, 0, 0, 0),
132        (0, 0, 0, 0, 0, 0, 7, 8, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0),
133        (0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
134        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
135        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
136        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
137        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
138        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), (
139    
140        (0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
141        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
142        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
143        (0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0),
144        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
145        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
146        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
147        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
148        (0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
149        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
150        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
151        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
152        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
153        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 4, 0, 0, 0, 0),
154        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
155        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
156        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
157        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
158        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
159        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
160    
161        );
162  var  var
163    i: integer;    i: integer;
164    j: integer;    j: integer;
165  begin  begin
166    for i := 0 to Wid - 1 do    for i := 0 to Wid - 1 do
167      for j := 0 to Hei - 1 do      for j := 0 to Hei - 1 do
168        FFlightData[i, j] := AData[j, i];        FFlightData[i, j] := AData[Pattern][j, i];
169    end;
170    
171    procedure TEnemy.Clear;
172    begin
173      Visible := false;
174      inc(FPattern);
175      if Kind = Pattern then
176        Pattern := 0;
177      Buffer;
178      Index := 0;
179      if HardSearch = true then
180      begin
181        X := AX * Size;
182        Y := AY * Size;
183        Search;
184      end
185      else
186        Clear;
187    end;
188    
189    constructor TEnemy.Create;
190    begin
191    Speed := 4;    Speed := 4;
192      Pattern := -1;
193    Clear;    Clear;
194  end;  end;
195    
# Line 209  begin Line 273  begin
273    X := false;    X := false;
274    if Length < Image1.Bitmap.Height - Hei * Size then    if Length < Image1.Bitmap.Height - Hei * Size then
275    begin    begin
276      inc(Length, 1);      inc(Length);
277      if Length >= Enemy then      if Length >= Enemy then
278        begin
279        if List.Count = 0 then        if List.Count = 0 then
280          for i := 1 to 10 do          for i := 1 to 10 do
281            List.Add(TEnemy.Create)            List.Add(TEnemy.Create);
282        else        X := true;
283          for i := 0 to List.Count - 1 do
284        begin        begin
285          X := true;          s := List[i];
286          for i := 0 to List.Count - 1 do          if s.Visible = true then
287          begin          begin
288            s := List[i];            X := false;
289            if s.Visible = true then            break;
           begin  
             X := false;  
             break;  
           end;  
290          end;          end;
291        end;        end;
292        end;
293    end;    end;
294    for i := 0 to List.Count - 1 do    for i := 0 to List.Count - 1 do
295    begin    begin
# Line 264  begin Line 327  begin
327    PaintBox1.Repaint;    PaintBox1.Repaint;
328  end;  end;
329    
330  procedure TEnemy.HardSearch;  function TEnemy.HardSearch: Boolean;
331  var  var
332    i, j: integer;    i, j: integer;
333  begin  begin
334      inc(FIndex);
335      result:=false;
336    for i := 0 to Wid - 1 do    for i := 0 to Wid - 1 do
337      for j := 0 to Hei - 1 do      for j := 0 to Hei - 1 do
338        if FFlightData[i, j] = Index then        if FFlightData[i, j] = Index then
339        begin        begin
340          AX := i;          AX := i;
341          AY := j;          AY := j;
342            result := true;
343          Exit;          Exit;
344        end;        end;
   Visible := false;  
   Clear;  
345  end;  end;
346    
347  procedure TEnemy.Search;  procedure TEnemy.Search;
# Line 306  begin Line 370  begin
370      AX := AX + 1;      AX := AX + 1;
371      AY := AY + 1;      AY := AY + 1;
372    end    end
373    else    else if HardSearch = false then
374      HardSearch;      Clear;
375  end;  end;
376    
377  { TChar }  { TChar }

Legend:
Removed from v.1  
changed lines
  Added in v.2

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