Page 1 of 1

Need Help

PostPosted: Thu Jul 05, 2007 1:33 am
by cracer21
im working on a game where the player has to bounce differently colour balls into differently coloured boxes. after each ball is in a box i want to have the next level loaded. i know tht a new level is basically a new game and i have to use the 'LoadGame' function to load it but, does anyone know how i can load the next level only after each ball has been placed in its own secific box?

PostPosted: Thu Jul 05, 2007 1:51 am
by Sgt. Sparky
make a variable(integer->global) called count.
when each ball collides with the right box,
Code: Select all
count++;
DestroyActor("Event Actor");

on the draw actor event of the view,
Code: Select all
if(count > what-you-want-it-to-be)LoadGame("yourlevel");

:D

PostPosted: Thu Jul 05, 2007 4:17 pm
by cracer21
so if had 4 balls annd im loading level 2 it would be:

Code: Select all
if(count > 4)LoadGame("level2");


?

PostPosted: Thu Jul 05, 2007 7:08 pm
by Jay S.
Basically, yes. :)

However, I may be mistaken, but it might be better to use this code instead:

Code: Select all
if(count >= 4)
{
     LoadGame("level2");
}


This way, if count is equal to or greater than 4, it will load the next level. Just using (count > 4) would mean that the action would only occur if count is over 4. :( So that would mean it would have to be 5 or more...

I hope this has helped you. :)

PostPosted: Thu Jul 05, 2007 9:10 pm
by cracer21
yep it has thanx :D

PostPosted: Fri Jul 06, 2007 12:34 am
by Jay S.
You're welcome! :D

PostPosted: Fri Jul 06, 2007 3:04 am
by Fuzzy
Jay S. wrote:Basically, yes. :)
Code: Select all
if(count >= 4)
{
     LoadGame("level2");
}




A nice Concise example Jay S. Well said. If I see you helping people again, I think I will give you a point!

A little used, but sometimes useful trick is this alternate way of doing that..

Code: Select all
if((count+1) > 5)
{
    LoadGame("level2");
}


or better yet..

Code: Select all
if((count-bonus) > 5)
{
    LoadGame("level2");
}


Which might be useful for loading the next level, but not taking bonus points into account.

For the most part though, you want to be as complete and concise as possible in an if() statement. Using the equal sign with greater/lesser is a good way to avoid nasty little bugs.