Thema: Pacman

Einzelnen Beitrag anzeigen

Blubbel

Registriert seit: 6. Okt 2011
125 Beiträge
 
Delphi 2010 Professional
 
#9

AW: Pacman

  Alt 8. Feb 2012, 15:47
Delphi-Quellcode:
 //Spieler und Monster
  TphItem = class(TObject)
  private
    FName: String;
    FSize: Integer;
    FPosition: TPoint;
    procedure GetName(const Value: String);
    procedure GetSize(const Value: Integer);
    procedure GetPosition(const Value: TPoint);
  public
    constructor Create();
    destructor Destroy();
    property Name: String read FName write GetName;
    property Size: Integer read FSize write GetSize;
    property Position: TPoint read FPosition write GetPosition;
  end;

  //Spielfigur
  TphPlayer = class(TphItem)
  private
  
  public
    constructor Create();
    destructor Destroy();
  end;

  //Gegner (Monster)
  TphMonster = class(TphItem)
  private

  public
    procedure Draw(ACanvas: TCanvas);
    constructor Create();
    destructor Destroy();
  end;


.........................


TphGameField = class(TObject)
  private
    FArray: Array of Array of Byte;
    FPlayer: TphPlayer;
    FMonsters: TObjectList;
    FViewPort: TphViewPort;
    FSize: Integer;
    FPosition: TPoint;
    FCount: Integer;
    FMonsterArray: Array [0..20] of TphMonster;
    procedure SetPosition(const Value: TPoint);
  protected
    function InitArray(AWidth, AHeight: Integer): Boolean;
  public
    constructor Create(AWidth, AHeight, ASize: Integer);
    destructor Destroy(); override;
    function MovePlayer(ADirection: Byte): TPoint; //????????????????????????
    procedure DrawGameField(ACanvas: TCanvas; AClipRect: TRect);
    procedure DrawPlayer(ACanvas: TCanvas);
    procedure DrawMonsters(ACanvas: TCanvas);
    property Player: TphPlayer read FPlayer {write SetPlayer};
    property ViewPort: TphViewPort read FViewPort {write SetViewPort};
    Property Position: TPoint read FPosition write SetPosition;
  end;
  Mit Zitat antworten Zitat