unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Shape1: TShape;
Shape2: TShape;
Timer1: TTimer;
Edit1: TEdit;
links: TTimer;
Edit2: TEdit;
rechts: TTimer;
procedure linksTimer(Sender: TObject);
procedure rechtsTimer(Sender: TObject);
procedure FormKeyPress(Sender: TObject;
var Key: Char);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
y : integer;
// für den Sprung
t : integer = 0;
// für den Sprung
d : integer = 7;
// für den Sprung
k : integer = 3;
// Für den Turbo
zr : integer = 0;
// Zeit für Timer: Rechts
zl : integer = 0;
//Zeit für Timer: Links
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
t := 0;
if timer1.Enabled = false
then timer1.Enabled := true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var yy : integer;
v : integer;
begin
t := t + 1;
v := 50
div d;
yy := abs(round(100*sin(t/v)));
edit1.Text := inttostr(yy);
shape1.Top := y - yy;
if round(100*sin(t/v)) <= 0
then timer1.enabled := false;
If g = 1
then shape1.Left := shape1.Left + 5;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
y := shape1.top;
end;
procedure TForm1.FormKeyPress(Sender: TObject;
var Key: Char);
begin
if key = #119
then begin //Sprung
t := 0;
if timer1.Enabled = false
then timer1.Enabled := true;
end;
if key = #100
then begin //Laufen nach rechts
zr:= 0;
if rechts.Enabled = false
then rechts.Enabled := true;
end;
if key = #97
then begin //Laufen nach links
zl:= 0;
if links.Enabled = false
then links.Enabled := true;
end;
end;