LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Generating DATA from a map editor

Root / Programming Questions / [.]

kitesinpowerlinesCreated:
For a future project, maps will be generated using DATA- I already know how to do this. However, I want to know how to do the opposite. I plan to have a map editor so players can create their own maps/puzzles but need to save the map as DATA. How would I convert player maps into DATA?

I am currently working on this problem too, and i used the commands(PRGGET$,PRGSET etc.) to write to the other program slots and save the DATA this way. Because you also have a limited amount of free space, i tried to keep the DIM of the active loaded map part pretty small and worked on an algorithm, so the player doesnt notice the loading time and recentering of the map. I can give you a more detailed example if you are interested, but perhaps other people here have better solutions.

I made 2 maps editor: One for "factory RPG" and other for a top down action rpg that I haven't finished yet. Factory RPG(Top-down attempt of a tactic rpg) The first use a .dat file to store the following data in this order: 1- Dimension of the map (Example: W,H) 2- An array of WxH of tiles 3- An array of WxH of metadata bind to the tile (To check if the tile is a wall, a floor, water, etc). 4- The number of entities (N) 5- A array of NX(Number of fields) of entities. I merge all that data on a single array (Using a custom function) to save this on a .dat file. To read the data I use other function that get the expected value from the array (String, number, string array, number array). Top-Down Action RPG Almost the same logic as above but instead of using .DAT I stored the map on TXT using LABELS and DATA. The hard part about this solution is to overwrite a previous label and it content from the file. I haven't share the code yet but the structure is somewhat complicated since it stores a layout of maps in one label that has references to other labels that store each room and a preview of it (A bitmap).

You could alternatively keep a 1D array of Tile_amount in game at number 3, that way you can use the tile number's meta data tag to determine it's properties.. ie 0 would be non solid 2 would be solid, 4 would be something else.. and then use a binary format to check flags on the tile. 2 4 8 16 32 64 This allows you to use binary AND or binary OR, and combine flags together to see which ones are on and off (in the bits)

Thanks for all the help, I haven't attempted yet because I have been working on other projects and such. I do have a few questions though:
I can give you a more detailed example if you are interested, but perhaps other people here have better solutions.
I am interested in this, if you wouldn't mind explaining more. It seems that it would be a simple fix to the problem, in theory.
I made 2 maps editor: One for "factory RPG" and other for a top down action rpg that I haven't finished yet. Factory RPG(Top-down attempt of a tactic rpg) The first use a .dat file to store the following data in this order: 1- Dimension of the map (Example: W,H) 2- An array of WxH of tiles 3- An array of WxH of metadata bind to the tile (To check if the tile is a wall, a floor, water, etc). 4- The number of entities (N) 5- A array of NX(Number of fields) of entities.
This seems like the ideal way of converting maps created in an editor as DATA; however, I don't understand 4-5 (what are entities?). Also, I'm having a hard time wrapping my head around merging those arrays together. I did download Factory RPG a while ago, perhaps I will take a look at the code and see if I can understand.

Entities would be any objects other than tiles, like enemies, items, etc.

Ah okay. I understand. Thanks!