February 07, 2012, 04:12:26 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: NextLevel Function HELP???  (Read 610 times)
Kor
Newbie
*
Posts: 39



View Profile
« on: March 02, 2010, 04:32:49 PM »

Okay so I'm an Insight student and I have been in 3D Game Design this semester. However I have been 3d modeling for 2 years. so i asked the instructor if i could make my games from scratch (using the empty game template) she told me that was fine. so the first game went well and now I'm stuck on the second one. this is the first game in which there is a level change. so I have both levels completely made but how to get from one to the other is where im lost. my programming skills are lacking so dont harsh on me cause I DO know that this is a very simple concept.

In the lab they give us this code and tell us to place it in our main.gsl file


They tell us to paste this

bool checkpoint1Activated = false;
Object@ checkpoint1 = game.GetWorld().GetObject( "checkpoint1");

Under our
//main loop

line


then they have us paste this

void NextLevel( GameManager@ game, Viewport@ viewport, Player@ player, Object@ playerObject, String level_name)
{
    game.ShowTextPlain( "Level Complete");
    // use this next section to load a new level
    // show the loading screen
    ShowForm( "LoadingScreen");
    NewWorld();
    StartLoadingWorld( "../worlds/" + level_name);
    while (!DoneLoadingWorld())
       Delay( 3.0);
    // run the game script
    LoadScript( "main.gsl", "MainGame");
    HideForm( "LoadingScreen");
    Delay(3.0);
}


after the last } in the script

and then they have us paste this

if (checkpoint1 != null)
{
   if (checkpoint1.GetControllerVariableBool( "IsOn"))
   {             
      // has this trigger already been triggered?
      if (checkpoint1Activated == false)
      {
         NextLevel( game, viewport, player, playerObject, "world2.wld");
         // Break out of loop so this script exits
         break;
      }
   }
}


after the

while(true)
{




and yes i have the trigger rigged right and im pretty sure i put it in right.
and i just got alot of errors.

then i tried using their main.gsl that everyone else is using. and it came back and said "player inventory being counted by another object" i think or something to that effect...

what would really help me is just a tutorial or something that tells me how to take an empty projects main.gsl and trigger from the templates and get my player to the second level. ill supply both the schools main.gsl and my main.gsl


thank you in advance to anyone who reads this sorry its so long and thanks to anyone who helps
Logged

Every artist was first an amateur.
-Ralph Waldo Emerson
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #1 on: March 02, 2010, 04:43:23 PM »

here is a script that makes an object the level changer, also how to add the settings from a character to next level

Logged
Kor
Newbie
*
Posts: 39



View Profile
« Reply #2 on: March 02, 2010, 06:16:41 PM »

that got me in the right direction but when i get to the object it says "nextmap.gsl could not be found" sorry for being so nooby and thanks for the file pixel like i said it got me in the right direction im probably just being an idiot haha

thanks again in advance
Logged

Every artist was first an amateur.
-Ralph Waldo Emerson
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #3 on: March 02, 2010, 07:11:24 PM »

well the second map also must have a .gsl like main.gsl. So you choose a map and it's .gsl file. If you don't have one you can probably use same as your main.gsl, just changing the map name etc
Logged
Kor
Newbie
*
Posts: 39



View Profile
« Reply #4 on: March 02, 2010, 09:00:24 PM »

i tried that and it crashed gamecore   Huh

i think i did it right but not sure
Logged

Every artist was first an amateur.
-Ralph Waldo Emerson
Kor
Newbie
*
Posts: 39



View Profile
« Reply #5 on: March 02, 2010, 11:41:18 PM »

is there a load world? instead of load script?


sorry for all the trouble and thanks in advance
Logged

Every artist was first an amateur.
-Ralph Waldo Emerson
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #6 on: March 03, 2010, 05:20:11 AM »

Yes you can load a world. When you enter your project you have a load world button. You can also run the game demo with a certain .gsl. Pressing the button in the "run game" thingy
Logged
Kor
Newbie
*
Posts: 39



View Profile
« Reply #7 on: March 03, 2010, 07:02:30 AM »

No i mean in this part of the script you sent me


{
// have we triggered a level change?
// First, we need to get a pointer to our level change object
Object@ levelchange = game.GetWorld().GetObject( "levelchange");

// did we trigger the level change?
// ask the level change object if the player has activated the interact variable or not
if ( levelchange.GetControllerVariableBool( "interact") == true)
{
// if we get here, then the player HAS activated the level change, so we'll call the next level
LoadScript( "nextmap.gsl", "MainGame");
}
}


at the end where it says

LoadScript( "nextmap.gsl", "MainGame");

is there a way to re-write this to just load a .wld? and not a .gsl script?




as i've said before my programming knowlege is limited to a short crash course on C++ i took 2 years ago... that i barely paid any attention in anyway.

Sorry and thanks again if I'm getting too irritating just say "go away noob" haha

Logged

Every artist was first an amateur.
-Ralph Waldo Emerson
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #8 on: March 03, 2010, 11:01:25 AM »

well I see that some things are not stated there but:

In the new nextmap.gsl you have to include a load world function, here is example from athos:


Quote
void MainGame()
{
   //load the world file:
   NewWorld();
   //begin loading the world
   StartLoadingWorld("../worlds/level1.wld");
   while(!DoneLoadingWorld())
      Delay(0.01f);
   
   GameManager@ game       = GetGameManager();
   Player@ player          = game.CreatePlayer("Player",true);
   Object@ playerObject    = game.GetWorld().GetObject("playerDummy");
   Viewport@ viewport       = game.GetViewport("Main");

   player.AddToInventory(playerObject);
   
   //fade out to black
   viewport.FadeOut(0);
   
   SetRelativeMouseMode(true);

So as it says in the text:

Quote
This will call the game script for your next level, which activates the loading of that level etc as described in the docs.
Pretty simple, no?

So the nextmap.gls will be loaded that actives the StartLoadingWorld("../worlds/level1.wld");

Hope this helps
Logged
Kor
Newbie
*
Posts: 39



View Profile
« Reply #9 on: March 03, 2010, 04:18:47 PM »

okay I finally got it thanks so much pixel. and sorry again for being so nooby about coding like i said im a modeler not a coder :+) so thanks again.


also I hope this thread will help others too
Logged

Every artist was first an amateur.
-Ralph Waldo Emerson
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #10 on: March 03, 2010, 04:50:25 PM »

well i am not coder or modeler but I have alot of older scripts and they often are better than new ones Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!