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

DelphiX  (TDXDraw, TDXTimer, Delphi, TDXImageList)

.

. : . , , . , DelphiX, DelphiX:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

:

TDXDraw, DXDraw:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

Display, :

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

, Color clWhite.

TDXSpriteEngine, DXSpriteEngine:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

DXDraw DXDraw:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

, TDXTimer, DXTimer, Interval :

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

TDXImageList - , (). DXDraw TDXDraw:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

, - TDXInput, DXInput:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

:

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

Forma1 frmDelphiX1 .  TDXImageList Items. Object Inspector. , :

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

, ( , Object Inspertor-e ):

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

, Picture . :

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)

.  GameUnit , Spider , Bullet - . 

. ,  

TfrmDelphiX1 = class(TForm)

TfrmDelphiX1 = class(TDXForm)

, , OnCreate. . TfrmDelphiX1.FormCreate(Sender: TObject).

, , :

unit XGame1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, DXDraws, DIB, DXSprite, DXClass, DXInput;

 

type

  TfrmDelphiX1 = class(TDXForm)

    DXDraw: TDXDraw;

    DXSpriteEngine: TDXSpriteEngine;

    DXTimer: TDXTimer;

    DXImageList: TDXImageList;

    DXInput: TDXInput;

    procedure FormCreate(Sender: TObject);

    procedure DXTimerTimer(Sender: TObject; LagCount: Integer);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

  TPlayerSprite = class(TImageSprite)       //

  protected

    procedure DoMove(MoveCount: Integer); override; //

  end;

 

  TSpider = class(TImageSprite) //

  Protected

    //

    procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;

    procedure DoMove(MoveCount: Integer); override;

  public

    constructor Create(AParent: TSprite); override; //

    destructor Destroy; override; //

  end;

 

  TBullet = class(TImageSprite)

  protected

    procedure DoCollision(Sprite: TSprite; var Done: Boolean); override;

    procedure DoMove(MoveCount: Integer); override;

  public

    constructor Create(AParent: TSprite); override;

    destructor Destroy; override;

  end;

 

 

var

  frmDelphiX1: TfrmDelphiX1;

  i:boolean;

 

implementation

 

// *************** TBullet ***********

Procedure TBullet.DoMove(MoveCount: Integer);

Begin

  inherited DoMove(MoveCount);

  y:=y-5;  // , ?

end;

 

constructor TBullet.Create(AParent: TSprite);

begin

  inherited Create(AParent);

end;

 

destructor TBullet.Destroy;

begin

  inherited Destroy; //

end;

 

procedure TBullet.DoCollision(Sprite: TSprite; var Done: Boolean);

begin

  if Sprite is TSpider then dead;

  Collision;

end;

 

// *********** TSpider **************

Procedure TSpider.DoMove(MoveCount: Integer);

begin

   inherited DoMove(MoveCount);

   if x>= 500 then I:= false;    // X>=   >>>

   if x<= 0 then I:= true;     // X<=   <<<

   if i=true then X := X+1;

   if i=false then X := X-1;

   Collision;

end;

 

constructor TSpider.Create(AParent: TSprite); //

begin

  inherited Create(AParent);

  Image := frmDelphiX1.DXImageList.Items.Find('Spider');

  Width := Image.Width;

  Height := Image.Height;

end;

 

 

destructor TSpider.Destroy;  //

begin

  inherited Destroy;

end;

 

procedure TSpider.DoCollision(Sprite: TSprite; var Done: Boolean);

begin

  // TBullet,

  if Sprite is TBullet then dead;

  Collision; //

end;

 

// ********************* TPlayerSprite *********************

Procedure TPlayerSprite.DoMove(MoveCount: Integer);

begin

    inherited DoMove(MoveCount);

    //

    if isLeft in frmDelphiX1.DXInput.States then x:=x-5;

    //

    if isRight in frmDelphiX1.DXInput.States then x:=x+5;

    //

    if isup in frmDelphiX1.DXInput.States then

    begin

      with TBullet.Create(Engine) do

      begin

        PixelCheck := True;

        Image := frmDelphiX1.dxImageList.Items.Find('Bullet');

        //Image := frmDelphiX1.dxImageList.Items.Find('Spider');

        //

        X := Self.X+Self.Width  -40;

        //

        Y := Self.Y+Self.Height -80;

        Width := Image.Width;

        Height := Image.Height;

      end;

    end;

    if  y >= frmDelphiX1.DXDraw.SurfaceHeight-image.Height then  //

      y := frmDelphiX1.DXDraw.SurfaceHeight-image.Height;        //

    if  x >= frmDelphiX1.DXDraw.SurfaceWidth -image.Width  then  //

      x := frmDelphiX1.DXDraw.SurfaceWidth -image.Width;         //

    if  y <= 0 then

      y := 1;

    if  x <= 0 then

      x:=1;

end;

 

 

{$R *.dfm}

 

procedure TfrmDelphiX1.FormCreate(Sender: TObject);

begin

  i:=true;

  with TSpider.Create(DXSpriteEngine.Engine) do

  begin

     PixelCheck := True;            //

     Image := frmDelphiX1.dxImageList.Items.Find('Spider'); // ImageList`

     x:=10; // x

     y:=10;  // y

     Width := Image.Width;          //

     Height := Image.Height;        //

   end;

   with TPlayerSprite.Create(DXSpriteEngine.Engine) do

   begin

     PixelCheck := True;

     Image := frmDelphiX1.dxImageList.Items.Find('GameUnit');

     x:=500;

     y:=500;

     Width := Image.Width;

     Height := Image.Height;

   end;

end;

 

procedure TfrmDelphiX1.DXTimerTimer(Sender: TObject; LagCount: Integer);

begin

  if not DXDraw.CanDraw then exit; // DirectX

  DXInput.Update;

  DXSpriteEngine.Move(LagCount);

  DXSpriteEngine.Dead;

  DXDraw.Surface.Fill(clWhite);

  DXSpriteEngine.Draw;

  DXDraw.Flip;

end;

 

end.

. "" "". "" :

    DelphiX (TDXDraw, TDXTimer, Delphi, TDXImageList)


, *,   . 1274 "Delphi", Borland Delphi.. 


 

 

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