Results 1 to 3 of 3

Thread: TDirectDrawSurface's...

  1. #1


    Now this may seem completely stupid but as I have only been using DelphiX for a short time I need your help with an issue.

    Basically, if you have read some of my other questions you will know that I am trying to create a rather large RPG which uses a grid of 256x256. My Current method of drawing is to take the players position... then based on the screen size draw the tiles (11x11) in so as not to slow it down too much.

    I am currently trying create another layer by which to display trees and objects you can walk under. However, when I try and draw it using the same (11x11) tiles visible method it slows down. I know there are things called TDirectDrawSurface's, but I cant seem to draw onto these, I can only load one image or tile onto the surface? Is this right?

  2. #2


    I'm not sure what you have sofar, but here's a short overview of how you can use TDirectDrawsurface in your game.

    First the surfaces for your tiles.

    MAXTILES = 9;

    Tiles : array[0..MAXTILES] of TDirectDrawSurface;

    for imgCounter := 0 to MAXTILES do
    Tiles[imgCounter] := TDirectDrawsurface.Create(DXDraw1.ddraw);
    The images 0 through 9 correspond with the images in your dximagelist.

    Then you have your tilemap. I assume you'll use two maps one for the tiles and one for the objects. I'll only show you the tiles version, as the objectversion is nearly the same.

    MAPWIDTH = 250;
    MAPHEIGHT = 250;

    TileInfo : array [0..MAPWIDTH, 0..MAPHEIGHT ] of byte;

    You probably have you own load version, here's an very very basic one
    for xpos:=0 to MAPWIDTH do
    for ypos:=0 to MAPHEIGHT do
    TileInfo[xpos,ypos] := random(10);

    Then you can draw these tiles using:
    for xpos := 0 to (form1.Width) div 32 do
    for ypos := 0 to form1.Height div 32 do
    tiles[TileInfo[xpos, ypos],false);

    You can use objects in a similar manner.

    I hope some of this made any sense, I haven't cheched the code, so you may a warning or two (hope not)

    Otherwise you can also read tutorials 3 and 4 on my website. I have explained things (and more) much better.

  3. #3
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Randburg, South Africa


    Also see The Lions tutorials in the Tutorials and Links section.
    William Cairns
    My Games: (Currently very inactive)
    MyOnline Games: (Currently very inactive)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Comodo SSL