Thema: Delphi Tunneleffekt in Delphi

Einzelnen Beitrag anzeigen

Benutzerbild von WordsBG
WordsBG

Registriert seit: 17. Sep 2005
63 Beiträge
 
Delphi 7 Professional
 
#1

Tunneleffekt in Delphi

  Alt 13. Okt 2006, 14:56
Irgendwie hatte ich mal lust in Delphi was Grafisches zu realisieren und hab mit nem "Tunneleffekt" angefangen, also das es aussieht als würde man durch einen Tunnel fliegen/fahren/laufen.
Das hier kam raus:

Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Box: TPaintBox; { 600x400 !!}
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Y: Integer;
  buf: TBitmap;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
  X: Integer;
begin
  Y := Y + 5;
  X := Y*3 DIV 2;
  with buf.Canvas do
  begin
    Pen.Color := clWhite;
    Rectangle(0,0,600,400);
    Pen.Color := clBlack;
    Rectangle(300-X,200-Y,300+X,200+Y);
    { Second Box }
    if (Y-100) > 0 then
    begin
      X := (Y-100)*3 DIV 2;
      Rectangle(300-X,200-(Y-100),300+X,200+(Y-100));
    end;
    { /Second Box }
    MoveTo(0,0);
    LineTo(600,400);
    MoveTo(600,0);
    LineTo(0,400);
  end;
  if Y > 200 then
    Y := 100;
  Box.Canvas.Draw(0,0,Buf);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Y := 100;
  buf := Tbitmap.Create;
  buf.Height := 400;
  buf.Width := 600;
end;

end.
Ich wollte nur fragen ob ich es a) noch optimieren kann, b) ob es andere gute Ansätze gäbe (DelphiX hab ich aber keine Lust zu, viel zu Platformspeziefisch), und c) ob jemand ne Idee hat ob es möglich ist Kurven oder sowas einzubauen das es mehr Achterbahnmäßig aussieht.
  Mit Zitat antworten Zitat