How do you use the "stage" command in the game and what is it used for?
From ggc
I have looked at a few other games and notice that there was the "stage=1" or "stage=2" commands. What are they used for and how do you use them?
Here's the basic idea. Assume you have your game working for the first part of the game - that is when the player clicks on a door another one opens. You don't want the game to continue in this way. The next part of the game is stay or switch, not choose any door. So what you have to do is do different things depending upon which sequence of the game you are playing. Here's some pseudo code:
if at the beginning let them click on any door and remove a different one from the prize door and the one they chose if past the beginning let them stay or switch if at the end tell them whether they won or lost
These three if statements can be done in Java using a stage integer. Think of stage==0 meaning at the beginning of the game, stage==1 meaning past the beginning, and stage==2 meaning at the end. What you do is update the stage when an event happens:
if(click!=null)
{
//in here they have clicked
if(stage==0)
{
//put beginning game statements here
//and stage=1 when they finished the beginning part
}
else if(stage==1)
{
//put past the beginning statements here
//and stage=2 when they finished the past the beginning part
}
else if(stage==2)
{
//put at the end statements here
//and stage=3
}
}
In this way, it only executes the part of your program you want when at a particular part of the game.
- This page was last modified on 31 January 2008, at 13:40.
- This page has been accessed 268 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









