Loading & Unloading levels/worlds

Non-platform specific questions.

Loading & Unloading levels/worlds

Postby DragonRift » Sun May 19, 2013 5:27 pm

My question is:
How you you handle loading & unloading Worlds/Levels in GE?

No one has really been able to answer this clearly.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby lcl » Sun May 19, 2013 6:24 pm

As most things, this can be done in multiple ways.
Here's some of them:

-separate .ged files exported as .dat files, loaded by using LoadGame();
-all levels in one .ged separated by activation regions for avoiding lag
-make a level editor for the game, make it to make the levels as files, which the game them reads and then generates the levels

As for building a level one usually uses tiles or clones (clones only when using exterior files for storing the level data). This goes for 2D platformer games, it really depends on what kind of game you are making.

In future, it would be easier to answer your questions if they were more specific, since things can always be done in many ways, but not all are efficient in all cases.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Sun May 19, 2013 7:26 pm

lcl wrote:As most things, this can be done in multiple ways.
Here's some of them:

-separate .ged files exported as .dat files, loaded by using LoadGame();
-all levels in one .ged separated by activation regions for avoiding lag
-make a level editor for the game, make it to make the levels as files, which the game them reads and then generates the levels

As for building a level one usually uses tiles or clones (clones only when using exterior files for storing the level data). This goes for 2D platformer games, it really depends on what kind of game you are making.

In future, it would be easier to answer your questions if they were more specific, since things can always be done in many ways, but not all are efficient in all cases.


in my context, each level is a "world" on my game and players will be able to travel between worlds, but I will be selling additional worlds via DLC and players will be able to chose which worlds they want included in the game when they start a new game.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby knucklecrunchgames » Sun May 19, 2013 10:58 pm

This may or may not help,

On the main menu there is elect world, but one of them says DLC, the player clicks into that and the game loads this DLC menu saying select your DLC world you wanna play.
Hope it helps, BTW I agree for the DLC, I'm all over it
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Mon May 20, 2013 1:01 am

knucklecrunchgames wrote:This may or may not help,

On the main menu there is elect world, but one of them says DLC, the player clicks into that and the game loads this DLC menu saying select your DLC world you wanna play.
Hope it helps, BTW I agree for the DLC, I'm all over it


I don't see this anywhere.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Mon May 20, 2013 7:53 pm

Ok, I now know how to Save/Load however the question now is:

Is there a way to share data between .dat files?
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby skydereign » Mon May 20, 2013 7:56 pm

You do so by saving and loading variables to a file. As long as both dat files can read the file, they can pass data to each other.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Mon May 20, 2013 8:01 pm

skydereign wrote:You do so by saving and loading variables to a file. As long as both dat files can read the file, they can pass data to each other.


Then this File can be easily Modified externally if I am not correct.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby skydereign » Mon May 20, 2013 8:06 pm

In a way yes. You don't have to store it in human readable form, as well as you can put in checksums to prevent tampering. But the file will need to exist, as that is the only way of passing data out of a game in gE.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Mon May 20, 2013 8:07 pm

skydereign wrote:In a way yes. You don't have to store it in human readable form, as well as you can put in checksums to prevent tampering. But the file will need to exist, as that is the only way of passing data out of a game in gE.


I see in the script that there is fopen, etc, are these C based or GE based so I know where to do my research.

Edit: C++ Ref

fclose
Close file (function )

freopen
Reopen stream with different file or mode (function )

setbuf
Set stream buffer (function )

setvbuf
Change stream buffering (function )

tmpfile
Open a temporary file (function )

tmpnam
Generate temporary filename (function )

I am trying to understand how to store stuff like Variable Information to/from flat files. Would you guys be able to help explain this stuff in detail in reference to how GE handles this since I see that I am not the only one in the community asking about this stuff.
Last edited by DragonRift on Mon May 20, 2013 8:12 pm, edited 1 time in total.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby skydereign » Mon May 20, 2013 8:12 pm

If you are using fopen you are dealing with FILE*, which is C. Alternatively, you could use saveVars/loadVars which are gE built in, that save variables using save groups.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Mon May 20, 2013 8:14 pm

DragonRift wrote:I am trying to understand how to store stuff like Variable Information to/from flat files. Would you guys be able to help explain this stuff in detail in reference to how GE handles this since I see that I am not the only one in the community asking about this stuff.


Could you assist with this?
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Loading & Unloading levels/worlds

Postby skydereign » Mon May 20, 2013 8:19 pm

Okay, first off, gE uses C, so C++ functions won't work. Also, really there is nothing special about file io in gE, so tutorials for how to do it in C will work just fine in gE.
Code: Select all
http://www.cprogramming.com/tutorial/cfileio.html


The general idea for writing to a file is you open a file with fopen. You write into that file with fprintf, and you close that file with fclose. Reading from a file is very similar, you open the file with fopen (mode set to r this time). You use the reverse operation, in this case fscanf is the opposite of fprintf. And again close the file when you are done.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Loading & Unloading levels/worlds

Postby DragonRift » Mon May 20, 2013 8:30 pm

skydereign wrote:Okay, first off, gE uses C, so C++ functions won't work. Also, really there is nothing special about file io in gE, so tutorials for how to do it in C will work just fine in gE.
Code: Select all
http://www.cprogramming.com/tutorial/cfileio.html


I think this is actually what I was looking for, because I am making a game where you are having to go in and out of different levels and are switching between side view and top view game modes. But the game needs to retain information between these state changes. I also wanted to have a local binary file database system for storing information like DLC Items unlocked in games. I realize a file can be hacked if someone really wanted to but most general users do not have the ability to do this.

And if hacking files became an issue then a person could enforce DRM but I would like to avoid taking that step.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron