Autor Beitrag
Danny W.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Mo 23.10.06 21:13 
Hallo,
da ich hier noch keine passende Lösung gefunden habe, ein neuer thread ^^

Ich würde gerne Schnee über mein Programm fallen lassen, am besten nur 2-3pt² groß. Diese sollen dann hin und her fliegen und bei komponenten wie z.B. einem TEdit kollidieren und sich sammeln..bzw. sich nach einer bestimmten zeit auflösen. Das alles soll über einen Timer aktiviert, bzw. deaktiviert werden.

ich dachte mir jetzt (doof wie ich bin^^)
gaaaanz viele kleine images, von links nach rechts. die nach ca. 20-30 sek. wieder nach oben transportiert werden. allerdings is das ziemlich speicherfressend. Man kann solche teile ja auch erzeugen lassen, was sinnvioller wäre. allerdings habe ich davon keine ahnung :(
Mit der Kollisionsabfrage hab ich mir auch schon ne menge durchgelesen. aber ich hab keine ahnung, wie sich der schnee z.B. auf einem TEdit sammelt... Ich glaube hier hatte jemand mal so ein Beispiel programm..wenn jemand sowas hat, bzw. lösungsansätze wäre ich sehr dankbar ^^

Moderiert von user profile iconraziel: "Drängel"-Link entfernt

mfG
Mantis
ROB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

Win98/WinXP
Delphi 4 Prof
BeitragVerfasst: Di 24.10.06 20:15 
Probiere es doch mit ner partikel engine da gibt es was bei DGL und im DGL-Wiki zum thema.

Good Luck
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Di 24.10.06 20:18 

_________________
Programmers never die, they just GOSUB without RETURN
Danny W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Di 24.10.06 20:35 
bei dgl hab ich nur gefunden, das jemand es mit einer for-schleife gelöst hat...ich habe mich ausserdem noch nie mit opengl befasst. Ausserdem wollte den Schnee mehr oder weniger auch nur als easteregg laufen lassen :) also soll nichts speicherfressendes, extremes, imperiator-mäßiges werden ^^ nur ein kleines plugin :> die kollision ist ja auch nur ne spielerei auf die verzichtet werden kann (aber nicht muss^^) :)

mfG
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: Di 24.10.06 21:46 
Ich hatte eben Lust und hab dir da mal was einfaches zusammengebastelt:

Man braucht nur einen Timer mit einem Interval von 50
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
    Snow: array[0..250] of TPoint;
    SnowBmp: TBitmap;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Math;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i, j: Integer;
  NewX, NewY: Integer;
begin
  Timer1.Enabled:=False;

  SnowBmp.Canvas.Pen.Color:=clBlack;
  SnowBmp.Canvas.Brush.Color:=clBtnFace;
  SnowBmp.Canvas.FillRect(SnowBmp.Canvas.ClipRect);

  for i:=Low(Snow) to High(Snow) do begin
    Snow[i].Y:=Snow[i].Y+2;
    if Snow[i].Y=SnowBmp.Height then
      Snow[i].Y:=0;

    NewY:=Snow[i].Y;
    if ControlCount>0 then
      for j:=0 to ControlCount-1 do
        if (NewY>=Controls[j].Top) and
           (Snow[i].X>=Controls[j].Left) and 
           (Snow[i].X<=Controls[j].Left+Controls[j].Width) then
          NewY:=Controls[j].Top-2;

    NewX:=Snow[i].X+Round(Sin(RadToDeg(NewY mod 360))*2);

    SnowBmp.Canvas.Pen.Color:=clWhite;
    SnowBmp.Canvas.Brush.Color:=clWhite;
    SnowBmp.Canvas.Ellipse(NewX-2, NewY-2, NewX+2, NewY+2);
  end;

  Canvas.Draw(0, 0, SnowBmp);
  Timer1.Enabled:=True;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Randomize;
  SnowBmp:=TBitmap.Create;
  SnowBmp.Width:=Width;
  SnowBmp.Height:=Height;
  for i:=Low(Snow) to High(Snow) do
    Snow[i]:=Point(Random(Width), Random(Height));
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  SnowBmp.Free;
end;


mfg
Danny W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Mi 25.10.06 07:44 
Das ist !EXAKT! das was ich wollte =) dankesehr vielmals :)
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 25.10.06 08:47 
da gibts ein programm das macht das fürs ganze Windows. schaut ur geil aus!

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Danny W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Mi 25.10.06 11:58 
ehrlich? würde mich mal interessieren, kennst evtl. noch den namen?

mfG
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Mi 25.10.06 13:02 
Darf ich kurz einen Tipp geben: In D3 läuft es auch, wenn man in uses Math einfügt.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 25.10.06 13:52 
user profile iconMantis1987 hat folgendes geschrieben:
ehrlich? würde mich mal interessieren, kennst evtl. noch den namen?
Die Suchbegriffe Schnee und Windows bei Google eingeben genügt da völlig:
www.windowspower.de/...BCr+Desktop_660.html
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 25.10.06 14:08 
@Phantom: :thumb: Um es perfekt zu machen, müssten die Schneeflocken jetzt noch Häufchenbilden, wenn sie auf einander fallen. Dann Darf natürlich immer nur die oberste Schneeflocke schmelzen. So sieht es etwas unreaklistisch aus, wenn die Flocken auf einem Kontrol landen. Bau das noch ein und es ist perfekt. ;)
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: Mi 25.10.06 14:25 
user profile iconLuckie hat folgendes geschrieben:
@Phantom: :thumb: Um es perfekt zu machen, müssten die Schneeflocken jetzt noch Häufchenbilden, wenn sie auf einander fallen. Dann Darf natürlich immer nur die oberste Schneeflocke schmelzen. So sieht es etwas unreaklistisch aus, wenn die Flocken auf einem Kontrol landen. Bau das noch ein und es ist perfekt. ;)

Es war ja wie gesagt nur ein einfaches Beispiel für Mantis1987, er kann ja wenn er will das ganze noch weiter verbessern :wink: Ich wüsste auch noch Verbesserungen zb unterschiedlich große Flocken und unterschiedliche Geschwindigkeit der einzelnen Flöckchen :)

mfg
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Mi 25.10.06 15:01 
Jau, und er hat es ja gerade erstmal "zusammengeschustert" - dafür alle Achtung, und es ist nach nicht mal ein Alpha Status...
Danny W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Mi 25.10.06 16:39 
user profile iconLuckie hat folgendes geschrieben:
@Phantom: :thumb: Um es perfekt zu machen, müssten die Schneeflocken jetzt noch Häufchenbilden, wenn sie auf einander fallen. Dann Darf natürlich immer nur die oberste Schneeflocke schmelzen. So sieht es etwas unreaklistisch aus, wenn die Flocken auf einem Kontrol landen. Bau das noch ein und es ist perfekt. ;)


Das wäre ja auch schon mit einer "selbstkollision" der einzelnen schneeflocken zu erreichen :)

//EDIT
wäre es evtl. möglich das jemand das da noch mit reinschreibt? ich habe das versucht, aber ich bekomme das nicht hin, da die werte nicht statisch sind und ich nicht weiß wie ich das random auslesen soll. Habs bis jetzt nur geschafft ein feld zu bewegen, das ein panel (oder ähnliches) nicht überschreiten darf.

mfG
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 26.10.06 23:42 
Hey das ist wirklich eine richtig coole Spielerei! Auch von mir Respekt!

Ich prophezeie, dass pünktlich zum Dezember jeder einen Weihnachtsskin für sein Programm anbietet :mrgreen:
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Fr 27.10.06 02:10 
Hab nochmal ein bisschen dran rumgebastelt
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:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, Math, StdCtrls;
type
  TSnow = record
    Position: TPoint;
    Size: Integer;
    speedx: Comp;
    speedy: Comp;
    wind: real;
    color: tcolor;
  end;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    private
    { Private-Deklarationen }
    Snow: array[0..1000] of TSnow;
    SnowBmp: TBitmap;
    Wind: Real;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Randomize;
  SnowBmp := TBitmap.Create;
  SnowBmp.Width:=Width;
  SnowBmp.Height:=Height;
  for i := Low(Snow) To High(Snow) Do
  Begin
    Snow[i].Size := 1;
    Snow[i].speedx := random(2) - random(2);
    Snow[i].speedy := random(5)+1;
    While Snow[i].wind = 0 Do
      Snow[i].wind := random(2) - random(2);
  End;
  Wind := random(50);
  i := 0;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  SnowBmp.Free;
end;

procedure TForm1.FormResize(Sender: TObject);
var
 i: Integer;
begin
  Timer1.Enabled := false;
  SnowBmp.Width:=Width;
  SnowBmp.Height:=Height;
  For i := Low(Snow) To High(Snow) Do
  Begin
    Snow[i].Position := Point(Random(Width), Random(Height));
    Snow[i].wind := random(2) - random(2);
  End;
  Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i, j: Integer;
  Newx, Newy: Integer;
begin
  wind := wind + random(1) - random(2);
  Timer1.Enabled := False;

  SnowBmp.Canvas.Pen.Color   := clBlack;
  SnowBmp.Canvas.Brush.Color := clblack;
  SnowBmp.Canvas.FillRect(SnowBmp.Canvas.ClipRect);
  for i := Low(Snow) to High(Snow) do
  Begin
    if Snow[i].Position.y > SnowBmp.Height then
    Begin
      Snow[i].Position.y := 0;
      Snow[i].Position.x := Random(SnowBmp.Width);
      Snow[i].speedy := Random(5);
      Snow[i].wind := random(2) - random(2);
    End;
    if Snow[i].Position.x > SnowBmp.Width then
      Snow[i].Position.x := 0;
    if Snow[i].Position.x < 0 then
      Snow[i].Position.x := 0;
    if Snow[i].Position.y < 0 then
    Begin
      Snow[i].Position.y := SnowBmp.Height;
      Snow[i].speedy := Random(5) - Random(2);
    End;
    Snow[i].speedy := Snow[i].speedy + (random(6) / 10) - (random(5) / 10) + 0.01;
    if round(Snow[i].speedy) = 0 then
      Snow[i].speedy := (random(500) / 541.56471) + 0.01;

    Snow[i].Position.y := Snow[i].Position.y + round(Snow[i].speedy);

    Newy := Snow[i].Position.y;
    if ControlCount > 0 then
      for j := 0 to ControlCount - 1 do
        if (Snow[i].Position.y >= Controls[j].Top) and
           (Snow[i].Position.y <= Controls[j].Top + Controls[j].Height) and
           (Snow[i].Position.x >= Controls[j].Left) and
           (Snow[i].Position.x <= Controls[j].Left + Controls[j].Width) then
          Newy := Controls[j].Top - 2;

    Snow[i].wind := Snow[i].wind + random(1) - random(1);
    Newx := Snow[i].Position.x + round(Snow[i].speedx) + round(Snow[i].wind * wind);

    SnowBmp.Canvas.Pen.Color   := clWhite;
    SnowBmp.Canvas.Brush.Color := Snow[i].Color;
    SnowBmp.Canvas.Ellipse(
    Newx - (Snow[i].Size),
    Newy-(Snow[i].Size),
    Newx+(Snow[i].Size),
    Newy+(Snow[i].Size));
  end;

  Canvas.Draw(0, 0, SnowBmp);
  Timer1.Enabled := True;
end;

end.
Einloggen, um Attachments anzusehen!
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 27.10.06 02:35 
user profile iconDanniolo hat folgendes geschrieben:
Hab nochmal ein bisschen dran rumgebastelt

Manche Leute haben einfach zu viel Zeit ;)

OT: ist das normal, dass FF2.0 bei dem Anhang die Möglichkeit 'Öffnen' nicht dabei hat? Nur Speichern geht :(

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Fr 27.10.06 02:42 
user profile iconMartok hat folgendes geschrieben:
user profile iconDanniolo hat folgendes geschrieben:
Hab nochmal ein bisschen dran rumgebastelt

Manche Leute haben einfach zu viel Zeit ;)
:mrgreen: gnarf ja vielleicht :P
Danny W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Fr 27.10.06 08:11 
das ist wirklich sehr genial :)

btw. habt ihr auch das problem, das damit keine labels mehr sichtbar sind? sprich. Wenn ich die funktion implementiere, verschwinden alle meine label ^^


mfG
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Fr 27.10.06 12:47 
Verschwinden direkt tun sie nicht, allerdings werden Labels von dem (eigentlich ja dahinterliegenenden) Canvas übermalt.