
Könnte mal bitte wer über den Code rüberscheuen, ich bekomme neuerdings den Fehler:
fmain.pas(175,3) Error: Illegal expression
fmain.pas(175,13) Fatal: Syntax error, ";" expected but "identifier TFORM1" found
Das ganze bezieht sich auf "procedure TForm1.FormKeyPress"
EDIT: Es scheint sich auf jede procedure zu beziehen ausser:
"procedure TForm1.FormCreate(Sender: TObject);"
Bitte keine zu große Fachsprache

Hier der Code:
Code: Alles auswählen
unit FMain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
tmrMoveBall: TTimer;
procedure FormCreate(Sender: TObject); {Gestaltung}
procedure FormKeyPress(Sender: TObject; var Key: char); {Steuerung}
procedure tmrMoveBallTimer(Sender: TObject); {KI (Bewegung) des Balls}
private
FBallX: integer;
FBallY: integer;
FDirection: integer;
FSpeed: integer;
FBatRightY: integer;
FBatLeftY: integer;
FScreenCenterX: integer;
FScreenCenterY: integer;
FBatRightX:integer;
FBatLeftX: integer;
procedure DrawBall(
const AXNew, AYNew: integer);
procedure DrawBatLeft(const AYNew: integer);
procedure DrawBatRight(const AYNew: integer);
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
uses
LCLType, MMSystem;
{$R *.lfm}
{ TForm1 }
const
CHeight = 500;
CWidth = 700;
CBallSpeed = 35;
CWinScore = 10;
CBatHeight = 80;
CBallSize = 15;
CServeAngle = 25;
procedure TForm1.FormCreate(Sender: TObject);
begin
Color:= clBlack;
Height:= CHeight;
Width:= CWidth;
Position:= poScreenCenter;
BorderStyle:= bsNone;
FBallX:= 0;
FBallY:= 0;
FSpeed:= CBallSpeed;
FScreenCenterX:= ClientWidth div 2;
FScreenCenterY:= ClientHeight div 2;
FBatRightX:= ClientWidth - 30 - CBallSize;
FBatLeftX:= 30;
procedure TForm1.FormKeyPress (Sender: TObject; var Key: char); {Steuerung}
begin
if Ord(Key) = VK_ESCAPE then
Close;
if Ord(Key) = VK_SPACE then
begin
DrawBall(FScreenCenterX, FScreenCenterY);
DrawBatRight(300);
DrawBatLeft (300);
tmrMoveBall.Enabled:= true; {Timer an}
end;
if Key in ['i', 'I'] then
DrawBatRight(FBatRightY + 20);
if Key in ['k', 'K'] then
DrawBatRight(FBatRightY - 20);
if Key in ['x', 'X'] then
DrawBatLeft(FBatLeftY + 20);
if Key in ['s', 'S'] then
DrawBatLeft(FBatLeftY - 20);
end;
procedure TForm1.tmrMoveBallTimer(Sender: TObject); {Selbstbewegung des Balles durch Timer/
Richtungsänderung}
var
LXChange: integer;
LYCHange: integer;
begin
// x2 = x1 + cos(direction) x speed
// y2 = y1 + sin(direction) x speed
LXChange:= trunc(cos(Pi / 180 * FDirection) * FSpeed);
LYChange:= trunc(sin(Pi / 180 * FDirection) * FSpeed);
DrawBall(FBallX + LXChange, FBallY + LYChange);
if (FBallX <= 0) or (FBallX >= ClientWidth - CBallSize) then
FDirection:= FDirection + (90 - FDirection) * 2
else if (FBallY <= 0) or (FBallY >= ClientHeight - CBallSize) then
FDirection:= FDirection + (180 - FDirection) * 2;
// FDirection:= FDirection * -1;
end;
procedure TForm1.DrawBall(const AXNew, AYNew: integer); {Ball/Größe}
begin
Canvas.Pen.Style:= psClear;
Canvas.Brush.Color:= ClWhite;
Canvas.Rectangle(FBallX, FBallY, FBallX + CBallSize, FBallY + CBallSize);
Canvas.Brush.Color:= ClBlack;
Canvas.Rectangle(AXNew, AYNew, AXNew + CBallSize, AYNew + CBallSize);
FBallX:= AXNew;
FBallY:= AYNew;
end;
procedure TForm1.DrawBatRight (const AYNew: integer);
begin
if (AYNew <= 0) or (AYNew + CBatHeight >= ClientHeight) then
Exit;
Canvas.Brush.Color:= ClWhite;
Canvas.Rectangle(FBatRightX, FBatRightY, FBatRightX + CBallSize, FBatRightY + CBatHeight);
Canvas.Brush.Color:= ClBlack;
Canvas.Rectangle(FBatRightX, AYNew, FBatRightX + CBallSize, AYNew + CBatHeight);
FBatRightY:= AYNew;
end;
procedure TForm1.DrawBatLeft (const AYNew: integer); {Marcel}
begin
if (AYNew <= 0) or (AYNew + CBatHeight>= ClientHeight) then {Thomas}
Exit;
Canvas.Brush.Color:= ClWhite;
Canvas.Rectangle(FBatLeftX, FBatLeftY, FBatLeftX + CBallSize, FBatLeftY + CBatHeight);
Canvas.Brush.Color:= ClBlack;
Canvas.Rectangle(FBatLeftX, AYNew, FBatLeftX + CBallSize, AYNew + CBatHeight);
FBatLeftY:= AYNew;
end;
end.