線上訂房服務-台灣趴趴狗聯合訂房中心
上鎖的討論區 上鎖的討論區 瀏覽次數:237
推到 Plurk!
推到 Facebook!

請問有關螢保的問題?

尚未結案
luhakeem
一般會員


發表:1
回覆:0
積分:0
註冊:2003-07-17

發送簡訊給我
#1 發表時間:2003-07-23 15:34:04 IP:211.78.xxx.xxx 未訂閱
請問各位網友: 我想做一個類似Windows內建螢幕保護程式(星際模擬)的效果,我的想法是在 FormShow事件時就隨機產生300個shape(星星).然後在Timer事件裡,以四個象 限的想法,讓shape往四面八方移動。 1.但是shape飄完後,shape要如何再生呢? 2.我以(例:star[i].Top:=star[i].Top+random(15))這樣的方式讓shape動,   但是會有跳躍的感覺,請問該怎樣修改,才能有流暢的感覺呢??    以下是我的程式碼,謝謝~~    unit flyingstar;    interface    uses   Extctrls,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs;    type   TForm1 = class(TForm)     Timer1: TTimer;     Image1: TImage;     Image2: TImage;     Image3: TImage;     Image4: TImage;     Image5: TImage;     Image6: TImage;     Image7: TImage;     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;       Shift: TShiftState; X, Y: Integer);     procedure FormShow(Sender: TObject);     procedure Timer1Timer(Sender: TObject);   private     { Private declarations }   public     { Public declarations }   end;    var   Form1: TForm1;    implementation   const Numofsnow=300;   var star:array[1..Numofsnow] of Tshape; {$R *.dfm}    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); begin   self.Close; end;    procedure TForm1.FormShow(Sender: TObject); var i:integer; begin  randomize;  for i:=1 to Numofsnow do   begin     star[i]:=Tshape.Create(self);     with star[i] do       begin         parent:=self;         brush.Color:=random(brush.Color);         shape:=stCircle;         top:=random(self.Height);         left:=random(self.width);         height:=random(6);       end;   end; end;    procedure TForm1.Timer1Timer(Sender: TObject); var i:integer; var signA,signB:integer; begin     for i:=1 to Numofsnow do     begin       signA:=(star[i].Top+star[i].Height);       signB:=(star[i].Left+star[i].Width);       if ((signA<(self.Height*0.5)) and           (signB<(self.width*0.5))) then         begin           star[i].Top:=star[i].Top-random(15);           star[i].Left:=star[i].Left-random(15);         end;          if ((signA>(self.Height*0.5)) and           (signB<(self.width*0.5))) then         begin           star[i].Top:=star[i].Top+random(15);           star[i].Left:=star[i].Left-random(15);         end;          if ((signA>(self.Height*0.5)) and           (signB>(self.width*0.5))) then         begin           star[i].Top:=star[i].Top+random(15);           star[i].Left:=star[i].Left+random(15);           if ((signA>=self.Height) or (signB>=self.width)) then         end;          if ((signA<(self.Height*0.5)) and           (signB>(self.width*0.5))) then         begin           star[i].Top:=star[i].Top-random(15);           star[i].Left:=star[i].Left+random(15);           if ((signA>=self.Height) or (signB=0)) then         end;     end; end;    end.
系統時間:2024-09-11 22:19:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!