Autor Beitrag
Phil511
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Di 06.02.07 17:24 
Hat jemand ne Idee wie ich folgendes ein bischen kurzer machen kann?
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
procedure TForm1.FormCreate(Sender: TObject);
var w :Integer;
begin
   //Wall

     With Spielfeld.Canvas do
        begin
           Brush.Color := HFarbe;
           pen.Width := 10;
           pen.Style := psSolid;
           brush.Style := bsSolid;
           pen.Color := RFarbe;
           Rectangle(0,0,Spielfeld.Width,Spielfeld.Height);
           Spielfeld.Canvas.Rectangle(0,0,Spielfeld.Width,Spielfeld.Height);
        end;

     SetLength(Wall,22);

     Wall[0].x :=80;
     Wall[0].y :=160;
     Wall[1].x :=100;
     Wall[1].y :=160;
     Wall[2].x :=120;
     Wall[2].y :=160;
     Wall[3].x :=140;
     Wall[3].y :=160;
     Wall[4].x :=160;
     Wall[4].y :=160;
     Wall[5].x :=180;
     Wall[5].y :=160;
     Wall[6].x :=180;
     Wall[6].y :=140;
     Wall[7].x :=180;
     Wall[7].y :=120;
     Wall[8].x :=180;
     Wall[8].y :=100;
     Wall[9].x :=180;
     Wall[9].y :=80;
     Wall[10].x :=180;
     Wall[10].y :=60;
     Wall[11].x :=320;
     Wall[11].y :=60;
     Wall[12].x :=320;
     Wall[12].y :=80;
     Wall[13].x :=320;
     Wall[13].y :=100;
     Wall[14].x :=320;
     Wall[14].y :=120;
     Wall[15].x :=320;
     Wall[15].y :=140;
     Wall[16].x :=320;
     Wall[16].y :=160;
     Wall[17].x :=340;
     Wall[17].y :=160;
     Wall[18].x :=360;
     Wall[18].y :=160;
     Wall[19].x :=380;
     Wall[19].y :=160;
     Wall[20].x :=400;
     Wall[20].y :=160;
     Wall[21].x :=420;
     Wall[21].y :=160;

   for w:= 0 to High(Wall) do
          begin
             pen.Width := 10;
             pen.Color := RFarbe;
             Rectangle(Wall[w].x -5,Wall[w].y -5,Wall[w].x +5,Wall[w].y +5);
             pen.Color := HFarbe;
             Pixels[0,0] := HFarbe;
             Rectangle(Wall[w].x -3,Wall[w].y -3,Wall[w].x +3,Wall[w].y +3);
             pen.Width := 1;
             pen.Color := RFarbe;
             MoveTo(Wall[w].x -5,Wall[w].y -5);
             LineTo(Wall[w].x +5,Wall[w].y +5);
             MoveTo(Wall[w].x -5,Wall[w].y +5);
             LineTo(Wall[w].x +5,Wall[w].y -5);
          end;
Einloggen, um Attachments anzusehen!
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 06.02.07 18:13 
Hallo und :welcome: in der Entwickler-Ecke!

Bei dem Konstrukt fällt mir auf, dass da ja 4 Wände aus diesen Wand-Teilen aufgebaut werden. Für jede dieser 4 Wände könnte man das in einer Schleife erledigen:

Aus
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
     Wall[0].x :=80; 
     Wall[0].y :=160; 
     Wall[1].x :=100; 
     Wall[1].y :=160; 
     Wall[2].x :=120; 
     Wall[2].y :=160; 
     Wall[3].x :=140; 
     Wall[3].y :=160; 
     Wall[4].x :=160; 
     Wall[4].y :=160; 
     Wall[5].x :=180; 
     Wall[5].y :=160;

könnte man dann sowas machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for i := 0 to 5 do
begin
  Wall[i].x := 80 + i*20;
  Wall[i].y := 160;
end;
Entsprechend bei den anderen.

_________________
We are, we were and will not be.