unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Menus, ExtCtrls;
type
TForm1 =
class(TForm)
MainMenu1: TMainMenu;
Menu: TMenuItem;
Start1: TMenuItem;
Beenden1: TMenuItem;
Image1: TImage;
Image2: TImage;
Timer1: TTimer;
procedure Beenden1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
procedure Start1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
d,f,g,x5,y5,x6,y6:integer;
implementation
{$R *.DFM}
procedure TForm1.Beenden1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
x5:=150;y5:=100;x6:=180;y6:=130;
d:=5;
image1.canvas.brush.color:=clwhite;
image1.canvas.rectangle(0,0,600,400);
image1.canvas.brush.color:=clmaroon;
image1.canvas.ellipse(x5,y5,x6,y6);
end;
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
image2.canvas.brush.color:=clnavy;
image2.canvas.rectangle(100,100,150,200);
if (GetAsyncKeyState(vk_up)<>0)
then image2.top:=image2.top-d;
if (GetAsyncKeyState(vk_down)<>0)
then image2.top:=image2.top+d;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
x5:=x5+f;y5:=y5+g;x6:=x6+f;y6:=y6+g;
with image1.canvas
do
begin
brush.color:=clwhite;
rectangle(0,0,600,400);
brush.color:=clmaroon;
ellipse(x5,y5,x6,y6);
if x5>=570
then f:=f*(-1);
if y5>=370
then g:=g*(-1);
if x6<=30
then f:=f*(-1);
if y6<=30
then g:=g*(-1);
end;
end;
procedure TForm1.Start1Click(Sender: TObject);
begin
timer1.enabled:=true;
end;
end.