unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, sSkinManager, Buttons, sBitBtn, StdCtrls, sButton, jpeg,
ExtCtrls, sPanel;
const dx=5;
dy=5;
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 }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var x,y:integer;
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;
x := dx; y := dy;
end;
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if reflektor.left > 110
then
begin
case ord(key)
of
vk_left:reflektor.left:=reflektor.left-14;
end;
end;
if (reflektor.left < 426)
then
begin
case ord(key)
of
vk_right:reflektor.left:=reflektor.left+14;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (Shape1.Top <= image1.Top + Shape1.Height )
or (Shape1.Top >= image1.ClientHeight - Shape1.Height)
then
begin
y := -y;
end;
if (Shape1.Left <= image1.Left + Shape1.Width )
or (Shape1.Left >= image1.ClientWidth - Shape1.Width)
then
begin
x := -x;
end;
Shape1.Left := Shape1.Left + x;
Shape1.Top := Shape1.Top + y;
Shape1.Repaint;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Enabled:=false;
end;
procedure TForm1.NeuesSpiel1Click(Sender: TObject);
begin
timer1.enabled:=true;
end;
end.