unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
jpeg, ExtCtrls;
type
TForm1 =
class(TForm)
Panel2: TPanel;
Timer1: TTimer;
Panel1: TPanel;
Keeper: TImage;
Image1: TImage;
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
ball: TBitmap;
public
end;
var
Form1: TForm1;
posx,posy,speedx,speedy,breite,hoehe:Integer;
implementation
{$R *.DFM}
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
repaint;
breite:=745;
hoehe:=441;
//Torwartbewegung Hoch-Runter
If Key=vk_down
then Keeper.Top:=Keeper.Top+5;
If Key=vk_up
then Keeper.Top:=Keeper.Top-5;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//Aprallen von Wänden
if posy >= hoehe-60
then speedy:= - speedy ;
if posy <= -40
then speedy:= - speedy ;
//Ball
Canvas.Draw(posx+40,posy+40, ball);
//Bewegung
posx:= posx + speedx;
posy:= posy + speedy;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//Ball create
ball:= TBitmap.Create;
ball.LoadFromFile('
ball1.bmp');
//Geschwindigkeit des Balls
speedx:=2;
speedy:=2;
end;
End.