Программирование - это просто
Advertisement
arrow Delphi arrow Delphi arrow (TObject, , , action, ).
07.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
(TObject, , , action, ). E-mail
megabax   
25.10.2009 .
New Page 2

(TObject, , , action, ).

, . . , , :

TEasyGameBaseClass=class(TObject)
end;

, . , :

TEasyGameNoun=class(TEasyGameBaseClass)
public
       procedure MakeQuantumOfTime; virtual; abstract;
end;

, ? " ", 1.1 ( ), Serialize Unserialize, .

, . - , . , ( ), . . - , ( ) - .

TEasyGameObject:

TEasyGameObject=class(TEasyGameNoun)
protected
       FOwner:TEasyGameContainer;
public
       procedure Action(ADestansion:TEasyGameObject; AAction:TEasyGameAction); virtual; abstract;
end;
 

, . TEasyGameObject Action. , TEasyGameAction - . ( ), ( ):

TEasyGameAction=class(TEasyGameBaseClass)
end;

(, ) . TEasyGameContainer:

TEasyGameContainer=class(TEasyGameNoun)
protected
     FObjects:TList;
public
    procedure AddGameObject(AGameObject:TEasyGameObject);
    procedure MakeQuantumOfTime; override;
end;

, 1.0:

TEasyGamePlatform=class(TEasyGameContainer)
protected
     FDateTime:TDateTime;
     FTimeSpeed:integer; // ( )
     FSizeOfQuantumOfTime:integer; //
     procedure SetTimeSpeed(ATimeSpeed:integer);
     procedure SetSizeOfQuantumOfTime(ASizeOfQuantumOfTime:integer);
public
    property DateTime:TDateTime read FDateTime;
    property TimeSpeed:integer read FTimeSpeed write SetTimeSpeed;
    property SizeOfQuantumOfTime:integer read FSizeOfQuantumOfTime write SetSizeOfQuantumOfTime;
    constructor Create(ADateTime:TDateTime);
    destructor Destroy;
    procedure MakeQuantumOfTime; override;
end;
 

TEasyGameContainer TEasyGameMap. , , , . : TEasyGameLocationObject:

TEasyGameLocationObject=class(TEasyGameObject)
protected
    FX,FY:integer;
    procedure SetX(AX:integer); virtual; abstract;
    procedure SetY(AY:integer); virtual; abstract;
public
    property X:integer read FX write SetX;
    property Y:integer read FY write SetX;
end;

, ? , 1000 1000. , . , ?  , - . , .

, ? , . . , , - . .

, , , 1.1

TEasyGameBaseClass=class(TPersistent)
protected
    FVersion:integer;
    function GetVersion:integer;
public
    procedure Serialize(AStream:TStream); virtual;
    procedure Unserialize(AStream:TStream); virtual;
end;
procedure TEasyGameBaseClass.Serialize(AStream:TStream);
var sign:string; version:integer;
begin
   Sign:=ClassName;
   version:=GetVersion;
   SerializeString(sign, AStream);
   AStream.Write(version,sizeof(version));
end;

procedure TEasyGameBaseClass.Unserialize(AStream:TStream);
var sign,s:string; l:integer;
begin
    sign:=UnserializeString(AStream);
    if sign<>ClassName then Raise Exception.Create('TEasyGameBaseClass.Unserialize: ()');
    AStream.Read(FVersion,sizeof(FVersion));
end;

. , TObject  TPersistent. , , , . RegisterClass, TPersistent. . . SerializeString, . . .

. . - :

if sign<>ClassName then Raise Exception.Create('TEasyGameBaseClass.Unserialize: ()');

? ,  .

, , , :

procedure TEasyGameLocationObject.Serialize(AStream:TStream);
begin
    inherited Serialize(AStream);
    AStream.Write(FX, sizeof(FX));
    AStream.Write(FY, sizeof(FY));
end;

, .

 

( 06.11.2011 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .