Helpful!
- *You can track the progress of loading the map
- *You can decide to load a part of the map
- *It's easy to understand
- *It's perfect to use if you want custom maps in your game (like Super Mario Maker)
- *It has virtually infinite amount of separate characters to save the map with
- *You can save more than one layer of a map in the TXT
- *You are able to save other things in the TXT as well as the map data (such as the map's name)
- *It's easy to extract data
- *There are many more pros to using this, but I can't name them all
- *Takes up more space
FOR BGY=0 TO 63 FOR BGX=0 TO 63 NUM=BGGET(0,BGX,BGY,0) MAPDATA$=MAPDATA$+CHR$(NUM+14) NEXT NEXT FOR BGY=0 TO 63 FOR BGX=0 TO 63 NUM=BGGET(1,BGX,BGY,0) MAPDATA$=MAPDATA$+CHR$(NUM+14) NEXT NEXT SAVE"TXT:TESTMAP",MAPDATA$This code was made specifically for a 64x64 map, but you can change it to what ever size you like. Anyways, what this does is scans the screen for the BG tiles and converts it into a string. It scans each tile one at a time, but it's actually really fast. The CHR$(13) bug is also avoided completely due to it increasing the CHR$() by 14. Simple right?! I almost forgot to mention, you have to have BG tiles on the screen in order to save it as a TXT file. Therefore, you can make a map and save it using DAT and then load it and save it as a TXT. Loading a map from a TXT file:
LOAD"TXT:TESTMAP",0 OUT MAPDATA$ BGSCREEN 0,127,127 BGSCREEN 1,127,127 FOR NUM=0 TO 4096 BGPUT 0,BGX,BGY,ASC(MAPDATA$[NUM])-14 BGX=BGX+1 IF BGX>=64 THEN BGY=BGY+1:BGX=0 BGNUM=0 NEXT BGX=0:BGY=0:NUM=4095 FOR NUM=4095 TO 8192 BGPUT 0,BGX,BGY,ASC(MAPDATA$[NUM])-14 BGX=BGX+1 IF BGX>=64 THEN BGY=BGY+1:BGX=0 BGNUM=0 NEXTOk, now things get a little bit more complicated but it's still simple. What this does is it loads the TXT file we previously made and then takes one character out of the string at a time, scans them, and then puts them in their proper place. As you can see, string mapping is quite simple. I initially made this so i can extract map collision data, but quickly found other uses for it. I hope you found this useful!!! I have begun remaking this engine for my new game on PC. I'll post a tech demo of both the PC and SB versions of this engine sometime.