\r\n \r\n I am actually coding a map-loader class for my game. In the beginning the map format was quite simple, and i could just read line after line and put things together. Now, my mapformat is getting more complicated, and its much easier to make the whole thing crash. I have done some PHP and i know what regular expressions are, but i never bothered to learn them (mostly because i never needed them), but i think thats the thing i have to use..
\r\n
\r\nMy maps are separated into four sections. Config, Terrain data, Object data and Trigger data. I want to read the whole file, then split it up using reg expr. To clearify this i\'ll make an example:
\r\n
\r\nThe map:
\r\n
\r\n
Code:
\r\n
[MAP_CONFIG:\r\nmap_name=Testmap\r\nmap_tileset=Default\r\n]\r\n[MAP_TERRAIN_DATA:\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n]\r\n[MAP_OBJECT_DATA:\r\ntree{pos=2,2;}\r\ntree{pos=6,3;}\r\n]\r\n[MAP_TRIGGER_DATA:\r\nhurt{pos=0,0;dmgamount=10;}\r\n]\r\n
Here i\'d like to separate the config, terrain data etc, like this:
\r\n
\r\nConfigVar =
\r\n
\r\n
Code:
\r\n
map_name=Testmap\r\nmap_tileset=Default
\r\n
TerrainDataVar =
\r\n
\r\n
Code:
\r\n
0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;
\r\n
etc...
\r\n
\r\nI really have no ideas how to do this. If you know some good tutorials, please post them here. Suggestions?? I dont care if i have to change the map format a little...
\r\n
\r\n-' + '- Loffen\r\n