When I select my first door, sometimes it reveals the door with the prize behind it. How do I get it to not reveal the prize on the first click of the mouse?

From ggc

Jump to: navigation, search

If you have an instance variable for where the prize is, you can do this with an if statement. In your instance variable declarations, suppose you have

private int prizeDoor;

and somewhere in your startGame method, you have a statement like:

prizeDoor=random.nextInt(3)+1;

then in your advanceFrame you can make sure not to open the prize door by checking the value of prizeDoor:

if(door1.intersects(click))
{
   if(prizeDoor!=1)
   {
      canvas.removeSprite(door1);
   }
}

This way when the player clicks on door1 it only is opened if it is not the prize door. See if this example helps you do what you want to do.





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter