Need Help

Non-platform specific questions.

Need Help

Postby cracer21 » Thu Jul 05, 2007 1:33 am

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?
cracer21
 
Posts: 3
Joined: Sat Jun 23, 2007 11:51 pm
Score: 0 Give a positive score

Postby Sgt. Sparky » Thu Jul 05, 2007 1:51 am

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby cracer21 » Thu Jul 05, 2007 4:17 pm

so if had 4 balls annd im loading level 2 it would be:

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


?
cracer21
 
Posts: 3
Joined: Sat Jun 23, 2007 11:51 pm
Score: 0 Give a positive score

Postby Jay S. » Thu Jul 05, 2007 7:08 pm

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. :)
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby cracer21 » Thu Jul 05, 2007 9:10 pm

yep it has thanx :D
cracer21
 
Posts: 3
Joined: Sat Jun 23, 2007 11:51 pm
Score: 0 Give a positive score

Postby Jay S. » Fri Jul 06, 2007 12:34 am

You're welcome! :D
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby Fuzzy » Fri Jul 06, 2007 3:04 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest