I am porting my game from Java to Objective C and I have a large amount of level data. I am hoping there is a simple way to change it over using some sort of replacement via regex.
The java format looks like this –
level1.addWave(240, 0, 120, 1, Constants.DOWN_STRAIGHT, .03f, 0.15f,
Constants.WANDER_RIGHT, Constants.TOP_SIDE, 250, 390, Sheep.WHITE, 2);
and the Objective C version should look like this –
[level1 addWave_offset:0 waveTimer:0 nextSheepCD:0 numberOfWaves:1 startingDirection:DOWN_STRAIGHT wanderRate:0.03 wanderLean:0.15
wanderDirection:WANDER_NONE side:TOP_SIDE minPixel:200 maxPixel:200 type:WHITE amount:1];
Is there a way to do this replacement via regex?
I have done similar things many times and my approach was following, i.e pseudo code:
– Iterate over all files in all directories
– Open file and read each line
– If your line starts with
levelthen do further processing– Further processing: Split the line with following tokens
(,Constants., and,. Trim the results to remove white spaces. Store each result in to associated temp variable (e.g. storelevel1intotmp_level_id)– Use store results to generate Objective-C code
While this may not be as beautiful as some funky regex it will be easier to implement and fix if necessary.
Kind regards,
Bo