unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, sSkinManager, Buttons, sBitBtn, StdCtrls, sButton, jpeg,
ExtCtrls, sPanel;
type
TForm1 =
class(TForm)
sSkinManager1: TsSkinManager;
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Hilfe1: TMenuItem;
NeuesSpiel1: TMenuItem;
Beenden1: TMenuItem;
Image1: TImage;
Startknopf: TsButton;
Pauseknopf: TsBitBtn;
reflektor: TImage;
Shape1: TShape;
Timer1: TTimer;
procedure PauseknopfClick(Sender: TObject);
procedure StartknopfClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure NeuesSpiel1Click(Sender: TObject);
private
{ Private-Deklarationen }
dx, dy: Integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PauseknopfClick(Sender: TObject);
begin
{Spiel pausieren und button pause unsichtbar --> Start sichtbar}
pauseknopf.visible:=false;
timer1.enabled:=false;
end;
procedure TForm1.StartknopfClick(Sender: TObject);
begin
{macht den pauseknopf sichtbar, setzt spiel fort}
timer1.Enabled:=true;
pauseknopf.Visible:=True;
dx := 5;
dy := 5;
end;
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
case ord(key)
of
vk_left:
if reflektor.left > 110
then
reflektor.left:=reflektor.left-14;
vk_right:
if (reflektor.left < 426)
then
reflektor.left:=reflektor.left+14;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (Shape1.Top <= image1.Top)
or (Shape1.Top >= image1.Top + image1.Height - Shape1.Height)
then
begin
dy := -dy;
end;
if (Shape1.Left <= image1.Left )
or (Shape1.Left >= image1.Left + image1.Width - Shape1.Width)
then
begin
dx := -dx;
end;
Shape1.Left := Shape1.Left + dx;
Shape1.Top := Shape1.Top + dy;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Enabled:=false;
end;
procedure TForm1.NeuesSpiel1Click(Sender: TObject);
begin
timer1.enabled:=true;
end;
end.