Results 1 to 8 of 8

Thread: Make it faster! Tilebased engine

  1. #1

    Make it faster! Tilebased engine

    Hi,

    Ive made a tilebased graphics engine. Problem is, that when im displaying 2 many transparent objects (tdximagelist transparent images) it gets slow, real slow.

    the way im doing it now is just a loop;

    for x:=iTilePointMinX to iTilePointMaxX do
    begin
    for y:=iTilePointMinY to iTilePointMaxY do
    begin

    DxImageList1.Items[aMap[x,y]].Draw(DxDraw1.surface, (x*80)-scrollX,(y*80)-scrollY, 0);


    end;
    end;

    the iTilePointMinX,iTilePointMaxX, etc are calculated based on what can actually be displayed (so no extra tiles will be drawed).

    After this, i would have a loop which draws the objects/sprites.

    the patternindex im setting to 0, im using a dximage par tile.
    Also, im stuffing all the images (tiles and objects/sprites) to systemmemory.

    How could i make this faster ?
    -= MvZ =-

  2. #2

    Make it faster! Tilebased engine

    DXImageList's systemmemory property only needs when DrawAlpha or
    DrawRotate may be faster.

    set all images to False would be faster.

  3. #3

    Make it faster! Tilebased engine

    What are the values of iTilePointMinX and iTilePointMaxX?

    In case you are using something like 0 to 255(x) x 0 to 255(y) it would decrease speed quite a bit. I'd recommend using an offset and only display those tiles that are visible on the screen.

    Not sure if this is your problem though. If not, please give us some info more to work with...

  4. #4

    Make it faster! Tilebased engine

    Quote Originally Posted by Traveler

    In case you are using something like 0 to 255(x) x 0 to 255(y) it would decrease speed quite a bit.
    Yes, and make array of coordinates in initialization (do not calculate in for cycle)

    Code:
      for x := 0 to width_tile_count do
        for y := 0 to height_tile_count do
          DrawImage(aMap[x+PosX,y + PosY],x,y);
          //Where PosX and PosY is your current desktop position
    
    procedre InitCoord;
    begin
      for x := 0 to width_tile_count do
          CoordX[x] := x*80;
      for y := 0 to height_tile_count do 
          CoordY [y] := y*80;
    end;
    
    procedure DrawImage(pSprite, pX, pY : Integer);
    begin
          DxImageList1.Items[pSprite].Draw(DxDraw1.surface, CoordX[pX]-scrollX,CoordY[pY]-scrollY, 0); 
    end;
    Letinjsh

  5. #5

    Getting there :D

    Thanx for replying mates,

    Excellent, so filling an array with screen positions (x*80,y*80) would improve speed much ? I'll try that !

    The bUseSystemMemory ive toyed with, but on my machines doest really matter (much). (Probably cause im not alphablending or rotating n stuff)

    Does bUseSystemMemory affect the speed of drawing transparent images of the dximagelist ?

    Also, arent there any fancy assembly routines I could use to draw a DxImagelist item on the dxdraw surface instead of the draw procedure ?

    And another question not about delphiX (im full of em);
    Currently im using a simple TClient- en TServerSocket to communicate between a client and server program.
    For some reason, when im using a simple socket.sendText, and right after this another socket.sendtext to the same host, the packages are sent together.

    For Eg.

    TmySocketServer.Socket.Connections[0].SendText('CLIENTACTION=blabla~~VALUE1=something') ;
    TmySocketServer.Socket.Connections[0].SendText('CLIENTACTION=groove');

    The receivedtext of the client would become
    CLIENTACTION=blabla~~VALUE1=somethingCLIENTACTION= groove

    Ive worked around this problem by using a seperator character, but still I think its pretty strange....
    Any idea how this could happen ?


    Cheers!!!!!
    Marius
    -= MvZ =-

  6. #6

    Please check the speed

    Allright,

    If you would be so kind so check if the speed is a bit urr normal;

    what im making is an online avatar chat world thing, called the AWorld.

    please download it at www.thevirtualplace.com

    ive just created a setup file, so i hope that works ok.

    if you find any other bugs or it doesnt work all together please email me at baggermail@gmx.net

    also urr the graphics are shite, so if youre a designer and you would like to create some nicer graphics for it, lemme know

    note that the server program is running local om my pc and my bandwidth (for pictures (objects,tiles)) isnt really fast, so keep that in mind.

    cheers!!
    Marius
    -= MvZ =-

  7. #7

    Make it faster! Tilebased engine

    It would probably be faster if you used one large ImageListItem for all the tiles, rather than separate items, and just set the PatternIndex to the tile that you want.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  8. #8

    Excellent

    Allright, thanx, I'll try that as well then
    -= MvZ =-

Bookmarks

Posting Permissions

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