PDA

View Full Version : Dynamic loading of TDXImageList



AthenaOfDelphi
02-01-2006, 08:37 PM
Hi all,

I'm starting to tinker with DelphiX for a little project, but I've come across a potential stumbling block. The general idea is to create a top down tiling engine ( I know there are probably already engines to do it, but its a learning thing :-) ).

Obviously, I need tiles, so I have at the moment, a 320x320 8bit bitmap. I load this and chop out each tile with a TDib and then store it in the TDXImageList, ala an example that comes with DelphiX.

My initial plan was to do this dynamically, allowing the user to modify the tile set on the fly, by removing unwanted/unused, loading new ones etc. etc.

And this is where I've encountered a problem. Once the form is displayed, no matter what I try, I can't get the tiles to be drawn on the TDXDraw surface. If I load them in the formCreate event handler, it works.

I've come to the conclusion that when the form is displayed, Direct X/DelphiX does some magic that buffers/initialises the image list and the surface to work with one another... can anyone shed any light on the issue? best of all... can anyone advise as to how to load the tiles once the form has been displayed, allowing me to dynamically change the tile set?

I've not ruled out changing from DelphiX if someone can provide me with a better alternative that doesn't bog me down in too much code.

Thanks in advance for any help :-)

FNX
02-01-2006, 09:26 PM
Hello AoD,
if you want to play with tiles with DelphiX I think you should have a look
to Tile Studio.

http://tilestudio.sourceforge.net/

It is a tile/map editor with export tool specific for DelphiX and of course
you can modify code once exported :)

About the dynamic tile/bmp/dib loading I think it's a limitation of DelphiX
more than being a problem of DirectX inizializing. Anyway I had the same
problem in the past and I could not solve it too. I simply load all the tiles
I need in the create/load stuff method and then I switch between images
runtime. So that if you have an array map you can tell which file to load
the tile from, or better, which pointer to tiles file to use for graphix.

I hope this helps :)

Bye

WILL
02-01-2006, 09:44 PM
I can personally vouch for the Tile Studio software myself. Very nice for making and testing your hand drawn tile sprites.

I did find incorporating the completed data files into my code quite a bit involved. I also didn't succeed. ;) But don't let that deture you, if you manage to get a working loadmap function, please by all means let us see. :)

AthenaOfDelphi
02-01-2006, 10:35 PM
About the dynamic tile/bmp/dib loading I think it's a limitation of DelphiX
more than being a problem of DirectX inizializing. Anyway I had the same
problem in the past and I could not solve it too. I simply load all the tiles
I need in the create/load stuff method and then I switch between images
runtime. So that if you have an array map you can tell which file to load
the tile from, or better, which pointer to tiles file to use for graphix.

I hope this helps :)


Hi FNX,

Help it did... it made me think about the processes that go on, and the fact that I've seen in one or two of the demos, the use of TDXDraw.finalize and TDXDraw.initialise.

Well... in my tile loader, I do TDXDraw.finalize before I start loading... load all the tiles... and then TDXDraw.initialize. It works :-) Seems the initialize method forces DelphiX/Direct X to do what it needs to allow using the tiles that I've just loaded.

I did take a look at Tile Studio... it looks like a neat tool, but I want an integrated editor that can edit the map and the scripting that goes with certain events/actions, plus theres this learning thing going on... have to brush up before the competition if I'm going to win ;-)

Thanks for the answers guys.

FNX
02-01-2006, 11:33 PM
Hi FNX, Help it did...

Nice :)


did take a look at Tile Studio... it looks like a neat tool, but I want an integrated editor that can edit the map and the scripting that goes with certain events/actions, plus theres this learning thing going on...

Well, actually there is not so much to learn about tiles but to represent
everything by a matrix of tiles insteand of pixels... Anyway I agree with
your point of view about learning!
I just suggested you TS because it's an easy way to see how to manage
things. Also about adding events is not difficult too if you write your own
class where you have property map (matrix), property tiles (one image
or array of image pointers) and the draw method is the one brought by TS.
The rest is up to you ;) Anyway it's just one of the millions ways you can
do it.


have to brush up before the competition if I'm going to win

I hope I can get in too! Pray for my customers not to ask 2 billions of
new features in the next months!! :roll: