Page 1 of 2

Newie Problem : Various levels in same file

PostPosted: Wed Mar 07, 2012 3:48 am
by AcisAce
I was looking forward to ask that how can i make different levels in the same .ged file.
Till now i was using the LoadGame command in script editor to link the title to the first level but i think that its not good option because people can then directly start next levels. My game is Based on Zombie Survival so i need help.
I hope someone will help me........

Re: Newie Problem : Various levels in same file

PostPosted: Wed Mar 07, 2012 4:44 am
by Hblade
You'd set up a "MAP" section, then use X and Y, like so:
Code: Select all
switch(MAP)
{
    case 0:
    break;
    case 1:
        view.x=min(2583, max(view.x, 288));
        view.y=min(-216, max(view.y, -648));
    break;
    case 2:
        view.x=min(3170, max(view.x, 3746));
        view.y=min(216, max(view.y, -216));
    break;
    case 3:
        view.x=min(4316, max(view.x, 3746));
        view.y=min(216, max(view.y, -648));
    break;
    case 4:
        view.x=min(6046, max(view.x, 4895));
        view.y=min(-648, max(view.y, -648));
    break;
}


switch(map), map is a variable. You can use what ever event you want to change the maps.
view.x=min(var1, max(view.x, var2); Var1 is the max X position the map can go, var2 is the minimum ammount the view can set.
same with y, only the first set of numbers is the lowest, and the second is the highest.

Re: Newie Problem : Various levels in same file

PostPosted: Wed Mar 07, 2012 5:24 pm
by SuperSonic
@AcisAce: It is actually better to use multiple files than to put your whole game in one big exe. But to fix the problem you stated, you can simply export your game as a dat file instead of exe and still use loadgame() :wink:

@Hblade: This is a little off topic but I never fully understood the max() function. Could you explain it please? :P

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 12:22 am
by skydereign
SuperSonic wrote:@AcisAce: It is actually better to use multiple files than to put your whole game in one big exe. But to fix the problem you stated, you can simply export your game as a dat file instead of exe and still use loadgame() :wink:

This is arguable. The reason I find using a single file is better is you don't have to recode it in every file. If gE allowed for importing actors, this would no longer be an issue. Also using a single file allows for quick moving between levels and menus, and you don't need to worry about saving variables over the jumps.

SuperSonic wrote:@Hblade: This is a little off topic but I never fully understood the max() function. Could you explain it please? :P

All max does is return the larger of the two numbers passed. So max(2, 5) would return a 5. min does the opposite. You can use these functions to limit variables one way or another.
Code: Select all
x = min(100, x+1); // increases x, but sets 100 as the max x value
// it does this because it returns the smaller number between the two
// if x+1 is smaller, it returns x+1 (meaning x was increased)
// but if x+1 is bigger, it returns 100

Again, min works the same way, but opposite. Now you can use both min and max in tandem to limit a variable in both directions.
Code: Select all
x = max(0, min(100, x));
// this limits x between 0 and 100
// min(100, x) returns the smaller of the two, meaning the value returned is no greater than 100
// then max(0, <value that is no greater than 100>) returns the larger of the two, meaning the return value must be greater than 0

Usually when using the min function, you are setting a max limit (no greater than), while when you use the max function you are setting a minimum limit (no less than). At first it may seem a bit backwards but it makes sense given the functions.

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 12:36 am
by SuperSonic
skydereign wrote:This is arguable. The reason I find using a single file is better is you don't have to recode it in every file

Yeah, that's true. I guess you could solve that by creating an engine. You know, that way you wouldn't have to recode everything :D

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 12:49 am
by skydereign
SuperSonic wrote:Yeah, that's true. I guess you could solve that by creating an engine. You know, that way you wouldn't have to recode everything :D

An engine? You mean the complete controls of your game, and similar? If that's the case then you are assuming it is perfect and no changes would need to be done, which in turn would be perfectly fine. I've found that assumption to be pretty much never accurate though, which is why I prefer a single file.

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 1:02 am
by SuperSonic
skydereign wrote:An engine? You mean the complete controls of your game, and similar? If that's the case then you are assuming it is perfect and no changes would need to be done, which in turn would be perfectly fine. I've found that assumption to be pretty much never accurate though, which is why I prefer a single file.

I'm not exactly sure what you mean. But when I say "engine", I usually mean a system that has all of the code for your game and simply loads external files such as bmp's and level data :D

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 1:59 am
by skydereign
Ah, I thought you were still talking about a multiple ged approach. Yeah, generally speaking that would be the 'optimal' approach to multiple levels as far as speed is and reusability is concerned. Of course it is the approach that takes the longest to setup.

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 2:57 am
by SuperSonic
skydereign wrote:Ah, I thought you were still talking about a multiple ged approach. Yeah, generally speaking that would be the 'optimal' approach to multiple levels as far as speed is and reusability is concerned. Of course it is the approach that takes the longest to setup.

Yeah, but it's worth it :P

Re:A Good idea :without scripting

PostPosted: Thu Mar 08, 2012 3:29 am
by AcisAce
a better idea is what ive got yesterday while i was resting.
we take a dot like sprite and put it on one corner of the view and make it views parent.
now whenever the level ends the dot will be programmed to move to a new area of the game where the next level starts
Hows that ?


Dont mind if its a stupid idea
Actually i am very new to this game editor and the language C too.

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 3:41 am
by skydereign
You could do that, but if you are going to do it that way, skip the whole parenting and individual actor. Just change the view's position when you want to move to another level. You can set the view's position like you could any other actor.
Code: Select all
view.x=1000;
view.y=1000;
// that moves the view to (1000,1000)

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 8:41 am
by AcisAce
hell..
why didnt i think of that ???
that was better.. view is itself an actor

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 9:05 am
by MrJolteon
AcisAce wrote:hell..
why didnt i think of that ???
that was better.. view is itself an actor

There's no need to post the same post three times in a row...

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 5:43 pm
by Hblade
MrJolteon wrote:There's no need to post the same post three times in a row...

I cleaned it up :3

Re: Newie Problem : Various levels in same file

PostPosted: Thu Mar 08, 2012 6:38 pm
by SuperSonic
MrJolteon wrote:There's no need to post the same post three times in a row...

That is usually an accident. It happened to me once :P