Files support

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
turshija
Posts: 127
Joined: Sat Feb 17, 2007 9:26 am
Location: Novi Sad, Serbia
Contact:

Files support

Post by turshija »

Need help ...
Is there any possibility to make ZGE program read levels from files but this way:
For example we have level1.txt file with this inside:

Code: Select all

5 5
XXXXX
XP  X
X  EX
X   X
XXXXX
1
So we make ZGE program that first reads the file, but only the first 2 numbers that represent the level dimensions. Then it reads the level, and after we finish the level he reads if the last number is 0 or 1 and that represents if there is level2.txt, and starts reading level2.txt automatically next level...
Because only thing I can manage to make with files, is the sepparate LevelLayoutFile component for each level, thats a little bit unpractical, coz I check for characters there, and spawn models depending on them.
The biggest problem there is updating ...
Whenever I add new character that represents some new object, I have to add it in all the LevelLayoutFile components ...
Any suggestions ?
Some .zgeproj files with it could be nice ... :roll:

Cheers
Boris
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Boris,

The simplest solution would be to stick to a single File loading procedure until you've implemented all of the features that you want. This approach is actually not all that uncommon among developers. During this development stage a sandbox / white-room level is used to explore / tweak all of the features, and actual level design ideally does not start until a green light is given. At this point you could copy the entire File component Tree to suit the number of levels you want to accommodate.

Another approach could be to only use one file for all of your levels. Just reserve a symbol to determine the beginning of level, width, height, end of level and end of file. Using conditional loops you should be able to Move all of the data from the File without the need to have separate File procedures.

Both might not be ideal, but it's probably not going to get better without the possibility to dynamically generate strings and set File properties.

Good luck ~
K
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Another approach:

Read data into a variables called LevelTilesWidth and LevelTilesHeight.

The first two characters cannot be ascii numbers (like "42") because you cannot parse strings to numeric. However you can use ascii codes, using 32 as zero to avoid control characters.

So a zexpression:
LevelTilesWidth-=32;
LevelTilesHeight-=32;

Then loop like you do now.

Code: Select all

%%
XXXXX
XP  X
X  EX
X   X
XXXXX
1
"%" is ascii code 37 (minus 32 is 5).
Post Reply