Autor Beitrag
Funnygirly
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mo 24.05.10 10:27 
Hallo,

ich habe es mittlerweile geschafft ein Haus zu zeichnen....jetzt muss ich aber noch mehrere zeichnen lassen, die dann im Zufallsprinzip auf der Canvas erscheinen. Ich weiß aber nicht wie ich das machen soll....kann mir jemand helfen?

Lg
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 24.05.10 10:31 
Hallo,

Da stellt sich erstmal die Frage: Wie zeichnest du das eine Haus? Wenn du eine Prozedur hast wie
procedure ZeichneHaus(Target: Canvas; x, y: integer);, die das Haus auf dem Canvas an Position x/y zeichnet, kann man mit Hilfe von Random sehr leicht gemacht werden, z.B. so:
ausblenden Delphi-Quelltext
1:
2:
for i := 1 to 5 do
   ZeichneHaus(canvas, random(800), random(600));

_________________
We are, we were and will not be.
Funnygirly Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mo 24.05.10 10:51 
Mein Haus sieht so aus:....

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:
79:
80:
81:
82:
unit uHaus;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
procedure zeichne_Haus(x,y : integer; a : real);   // Prozedur-Vereinbarung
var i:integer;
 begin
   with Image1.Canvas do
     // Seitenwände und Boden
     moveTo(x,y-round(a*3.5));
     lineTo(x,y);
     lineTo(x+round(4*a),y);
     lineTo(x+round(4*a),y-round(3.5*a));
     // Dach
     moveTo(x-round(a*1),y-round(a*2.5));
     lineTo(x+round(a*2),y-round(a*5.5));
     lineTo(x+round(5*a),y-round(2.5*a));
     // Tür
     moveTo(x+round(a*0.5),y);
     lineTo(x+round(a*0.5),y-round(a*2.5));
     lineTo(x+round(a*1.5),y-round(a*2.5));
     lineTo(x+round(a*1.5),y);
     // großes Fenster
     moveTo(x+round(a*2),y-round(a*1));
     lineTo(x+round(a*3.5),y-round(a*1));
     lineTo(x+round(a*3.5),y-round(a*2.5));
     lineTo(x+round(a*2),y-round(a*2.5));
     lineTo(x+round(a*2),y-round(a*1));
     moveTo(x+round(a*2),y-round(a*1.5));
     lineTo(x+round(a*3.5),y-round(a*1.5));
     moveTo(x+round(a*2),y-round(a*2));
     lineTo(x+round(a*3.5),y-round(a*2));
     moveTo(x+round(a*2.5),y-round(a*2.5));
     lineTo(x+round(a*2.5),y-round(a*1));
     moveTo(x+round(a*3),y-round(a*2.5));
     lineTo(x+round(a*3),y-round(a*1));
     // kleines Fenster
     moveTo(x+round(a*1.5),y-round(a*3.5));
     lineTo(x+round(a*2.5),y-round(a*3.5));
     lineTo(x+round(a*2.5),y-round(a*4.5));
     lineTo(x+round(a*1.5),y-round(a*4.5));
     lineTo(x+round(a*1.5),y-round(a*3.5));
     moveTo(x+round(a*2),y-round(a*4.5));
     lineTo(x+round(a*2),y-round(a*3.5));
     moveTo(x+round(a*1.5),y-round(a*4));
     lineTo(x+round(a*2.5),y-round(a*4));
     // Schornstein
     moveTo(x+round(a*1),y-round(a*4.5));
     lineTo(x+round(a*1),y-round(a*6));
     lineTo(x+round(a*1.5),y-round(a*6));
     lineTo(x+round(a*1.5),y-round(a*5));
   end;
 end;

begin
  zeichne_Haus(300,500,70);   // Prozedur-Aufruf
end;

end.




vll kann ich dies ein bisschen kleiner noch machen und dann noch mehrere davon? wie mache ich das dann hier?

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Tryer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 226
Erhaltene Danke: 7



BeitragVerfasst: Mo 24.05.10 10:57 
Wenn auch nur eine Zeile davon von dir wäre wüsstest du das.

www.hsg-kl.de/faeche...rafik/haus/index.php

Grüsse, Dirk
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 24.05.10 11:03 
Na, dann schau dir einfach nochmal mein Posting von eben an und pass das minimal an. Die kopierte Prozedur hat halt keinen Parameter für die Zeichenfläche, auf der das Haus entstehen soll, sondern für die Größe, wenn ich das richtig überblicke.

_________________
We are, we were and will not be.
Funnygirly Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mo 24.05.10 11:08 
@Tryer. stimmt dann wüsste ich dass wahrscheinlich, aber da ich eh nicht so gut mit Delphi umgehen kann und orgen die Arbeit schreib hab ich mir eben schnell eine Haus aus dem inet geshcnappt und versuche dass so anzupassen, wie ichs brauche, weil ich keine zeit mehr habe, denn ich muss noch des mit den Variablenparametern,des Hus, Arrays, Binärcode und noch andere Grafiksachen erlernen bis morgen. Ich mein ich mach ja schon ne ganze Zeit lang was dafür, is trotzdem net so einfach. Ich kann mit Delphi irgendwie net umgehn. Ich dachte älich eigentlich, dass wir in der 11 HTML und programmieren und sowas machen aba doch kein Delphi...^^

@Gausi: okay ich probiere es mal :) danke :) wie mach ich das eigentlich, dass des in so nem Quelltext angezeigt wird?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 24.05.10 11:18 
user profile iconFunnygirly hat folgendes geschrieben Zum zitierten Posting springen:
Ich dachte älich eigentlich, dass wir in der 11 HTML und programmieren und sowas machen
HTML ist kein Programmieren. ;-)
JavaScript auf Internetseiten natürlich schon. Aber das finde ich eher schwieriger als Delphi, weil das Debuggen nicht so einfach ist. (Merke ich gerade, weil ich im Moment damit anfange mehr zu machen. :mrgreen:)

user profile iconFunnygirly hat folgendes geschrieben Zum zitierten Posting springen:
wie mach ich das eigentlich, dass des in so nem Quelltext angezeigt wird?
Du musst einfach deinen Quelltext in Delphi-Tags setzen:
ausblenden Quelltext
1:
<span class="inlineSyntax"><span class="codecomment">{PROTECTTAG4a2bb00588a17fb10a6158e6fa8fe788}</span></span>					
Alternativ hast du über dem Eingabefeld auch unter Bereiche eine Auswahlbox dafür.
Funnygirly Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mo 24.05.10 11:30 
ah okay danke xD