Mega Code Archive

 
Categories / Delphi / Graphic
 

DXDraw example(DelphiX)

Title: DXDraw example(DelphiX) Question: If you need some simple examples of it. Answer: First you need to add DXImageList component into the form then load the image to the first item. For example lets take OnFormPaint procedure. procedure TForm1.FormPaint(Sender: TObject); begin DXImageList.Items[0].Draw(DXDraw.Surface, 10, 10, 0); DXDraw.Flip; end; This only shows the picture.And i'll show the second one which is greater, it's using with TImageSprite.Put the DXSpriteEngine component on the form, then find a property DXDraw and choose a value for it 'DXDraw'.Now you can write a code: var Player : TImageSprite; .... Player := TImageSprite.Create(DXSpriteEngine.Engine); With Player do begin Image := DXImageList.Items[0]; Z := 2; Width := Image.Width; Height := Image.Height; X := 10; Y := 10; end; ..... //Drawing DXDraw.Surface.Fill(0); DXSpriteEngine.Draw; DXDraw.Flip; ..... I'll show how to move your image with keybord arrows: ..... procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin If Key = 37 then Player.X := Player.X - 7; If Key = 38 then Player.Y := Player.Y - 7; If Key = 39 then Player.X := Player.X + 7; If Key = 40 then Player.Y := Player.Y + 7; //lets draw our results DXDraw.Surface.Fill(0); DXSpriteEngine.Draw; DXDraw.Flip; end; ....