unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TGame = class
bNorth : boolean;
bSouth : boolean;
bEast : boolean;
bWeast : boolean;
lastkey : byte;
private
function GetEast : boolean;
function GetNorth : boolean;
function GetSouth : boolean;
function GetWeast : boolean;
procedure SetEast (const Value: boolean);
procedure SetNorth (const Value: boolean);
procedure SetSouth (const Value: boolean);
procedure SetWeast (const Value: boolean);
public
function NE: boolean;
function NW: boolean;
function SE: boolean;
function SW: boolean;
function SimultanDir: byte;
function isBlocked: boolean;
property North : boolean read GetNorth write SetNorth;
property South : boolean read GetSouth write SetSouth ;
property East : boolean read GetEast write SetEast ;
property Weast : boolean read GetWeast write SetWeast ;
end;
implementation
{ TGame }
function TGame.NE: boolean;
begin
if bNorth=TRUE and bEast=TRUE then Result:=TRUE else Result:=FALSE;
end;
function TGame.NW: boolean;
begin
if bNorth=TRUE and bWeast=TRUE then Result:=TRUE else Result:=FALSE;
end;
function TGame.SE: boolean;
begin
if bSouth=TRUE and bEast=TRUE then Result:=TRUE else Result:=FALSE;
end;
function TGame.SW: boolean;
begin
if bSouth=TRUE and bEast=TRUE then Result:=TRUE else Result:=FALSE;
end;
function TGame.SimultanDir: byte;
begin
Result:=0;
if bNorth = TRUE then Inc(Result);
if bSouth = TRUE then Inc(Result);
if bEast = TRUE then Inc(Result);
if bWeast = TRUE then Inc(Result);
end;
function TGame.isBlocked: boolean;
begin
Result:=FALSE;
if SimultanDir>2 then Result:=TRUE
else if ( bEast=TRUE and bWeast=TRUE ) then Result:=TRUE
else if ( bNorth=TRUE and bSouth=TRUE ) then Result:=TRUE
end;
function TGame.GetEast: boolean;
begin
Result:=bEast;
end;
function TGame.GetNorth: boolean;
begin
Result:=bNorth;
end;
function TGame.GetSouth: boolean;
begin
Result:=bSouth;
end;
function TGame.GetWeast: boolean;
begin
Result:=bWeast;
end;
procedure TGame.SetEast(const Value: boolean);
begin
bEast:=Value;
end;
procedure TGame.SetNorth(const Value: boolean);
begin
bNorth:=Value;
end;
procedure TGame.SetSouth(const Value: boolean);
begin
bSouth:=Value;
end;
procedure TGame.SetWeast(const Value: boolean);
begin
bWeast:=Value;
end;
end.