level chooser

Talk about making games.

level chooser

Postby Fojam » Sun Dec 19, 2010 9:00 pm

scenerio:
I have an executable file for my game, and all of the levels for that game are .dat files. I want to be able to create new levels without modifying the executable file.
Is there a way for game editor to list all of the .dat files in a certain directory so you can choose which one to launch when you start the game?
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: level chooser

Postby lcl » Sun Dec 19, 2010 10:28 pm

There is an easier way. You need to make a variable for the number of level to load.
Then when you need to load next level, you can write this code:
Code: Select all
char level[30];
sprintf(level, "level%i.dat", levelNumber);
loadGame(level);

Now you can make it so user can choose the number of level to load.
If you use this code, your levels must be named like level1, level2, ...

The code is untested but it should work. If it doesn't, I'll fix it and then send to you again. :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: level chooser

Postby Fojam » Mon Dec 20, 2010 1:48 am

Thanks but I'm looking for a way to be able to create custom levels anytime I want and for the game to list all of the levels I have in a particular folder and let me choose the level I want
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: level chooser

Postby skydereign » Mon Dec 20, 2010 6:37 am

You might try this. I've set this up and it works quite nicely. Create a file that has the names of all the levels within the directory. You can do this through a string array, or by exterior text files. The text files are easier, and can be edited without a game, but can be edited by other users (in this case it doesn't matter). Then your level loader menu type file will load up that list, and use LoadGame(stringVar). I set up a login system and other with this, for multiplayer interaction within other levels, so it should work just as said. But, if you do need any more explanation, ask.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: level chooser

Postby skydereign » Mon Dec 20, 2010 11:38 pm

There is no way of reading into the directory currently, which is why the string file is needed. Whenever you add a game, you will need to change the file, its the only way to know what is in the file. You could create a program not in gameEditor that updates that file, but it needs to be there.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: level chooser

Postby Fojam » Mon Dec 20, 2010 11:42 pm

if you install the dat files via debian, is there a way to just add a string to that text file without affecting the rest of the text file?
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest