All pastes #291050 Raw Edit

Someone

public text v1 · immutable
#291050 ·published 2006-12-24 18:25 UTC
rendered paste body
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
    { Private declarations }
  public
    { Public declarations }

    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;

end.