1. Tile-Based Map Editor Dilemma
- Posted by Aen Aen <Fist1000 at AOL.COM> Nov 07, 1998
- 358 views
Hey Euphorians, Here's a puzzle for you: I'm working on an option for tile-based map editor to import an image, chop it up into tiles, and create a map layer with it. The catch is, I need it to be able to eliminate duplicate tiles in the tile bay while still maintaining the 'visual order' of the map. This is something that proves useful for people importing snapshots from console emulators and the like. It's in mode 19 and all the tiles are 16x16, stored sequentially in one large array. Something like this: integer numtiles numtiles = 100 atom vsp -- tile bay vsp = allocate(256 * numtiles) The map data is stored similarly: integer mapwide, mapdeep mapwide = 100 mapdeep = 100 atom map map = allocate(mapwide * mapdeep) Each byte in the map data is basically an index to the appropriate tile to display from the tile bay. So, given a tile index, you'd find its starting point in the tile bay by doing something like: map + (tile * 256). At the moment I basically just load in the image, and divide the dimensions by 16 to get the number of whole tiles that I can extract along the width and height. Then I create a temporary tile bay that's (width * height * 256) bytes and patch all the whole tiles into the temporary tile bay. Then I just destroy and reallocate the layer and stuff in all the tiles from the temporary tile bay on after the other. I figured that might somehow be simpler than checking for duplicates while grabbing from the image? It's all just a muddle in my brain. :) I'm unsure how to create a list of unique tile indexes and then go about removing duplicates without disrupting things. For example, if I delete all the duplicates of one tile from the tilebay, the tile indexes in the map data that were correct before are then rendered incorrect. I'd need to adjust the indexes, of course, but I find it very difficult to solve. If you need further information, go right ahead and ask. I'm coding this in C, but I intend on porting it over to EUPHORIA after it's all finished. For fun, and for the learning experience. You don't necessarily need to throw an entire coded solution at me, I just need a little direction as to how I get from point A to point B without a hernia. :) Thanks, aen
2. Re: Tile-Based Map Editor Dilemma
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Nov 07, 1998
- 371 views
- Last edited Nov 08, 1998
It would have been easier to check for duplicates while grabbing the image, but this will, (I think), work: Have a new index-list, that contains the index to the *old* index list. And then apply such a list onto the current map. Replace every index is the new list, with the index the old one was pointing to, and you're done. Ralf