PDA

View Full Version : Make it faster! Tilebased engine



hassah
27-08-2003, 12:50 PM
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 ?

DraculaLin
27-08-2003, 03:20 PM
DXImageList's systemmemory property only needs when DrawAlpha or
DrawRotate may be faster.

set all images to False would be faster.

Traveler
27-08-2003, 10:42 PM
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...

ra001
28-08-2003, 06:18 AM
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)



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;

hassah
28-08-2003, 07:58 AM
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

hassah
28-08-2003, 03:59 PM
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

Useless Hacker
28-08-2003, 08:01 PM
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.

hassah
28-08-2003, 08:09 PM
Allright, thanx, I'll try that as well then :D