Figure 1
… Let’s say you meditate on the color of the invisible box and then click on the RED box in the Key…but the “invisible box” was Blue. The following is what your canvas should now look like:
But let’s say your ESP was really strong and you clicked on the BLUE box in the Key…and the “invisible box” was Blue. The following is what your canvas should now look like:
(If you need some HINTS read on….)
In begin()….
Create a framed rectangle (100x100) and set it’s color (randomly to one of the four colors:
InvisibleSquare = new FilledRect(10,10,100,100,canvas);
ColorSelect = new RandomIntGenerator(1,4);
rgby = ColorSelect.getValue();
// now set the color of the “invisible” square
if(rgby == 1) // set the “Invisible” square to red
{
InvisibleSquare.setColor(Color.RED);
}
If(rgby==2) // set the “Invisible” square to blue
{
InvisibleSquare.setColor(Color.BLUE);
}
// and so on …
// Once the “invisible square” color is set – hide() it.
Create 4 other square at the bottom of the canvas: YellowSquare, RedSquare, BlueSquare, and GreenSquare
YellowSquare = new FilledRect(10,200,50,50,canvas);
RedSquare = new FilledRect(60,200,50,50,canvas);
// and so on
Create a Text object: IntroMsg = new Text(“Using your ESP Powers, click on a color which matches the color of the invisible square”, 150,10,canvas);
When the Mouse is clicked inside one of the boxes – find out which box was selected:
onMouseClick( Location pt)
{
if (RedSquare.contains(pt) ) // Check to see if the red square was clicked
{
// red was clicked
new Text ( “You got vibes that the box was RED”, 150,10,canvas);
// Now check to see if red is the color of the invisible box?
if ( InvisibleSquare.getColor() == Color.RED)
{
new Text( “And it was RED! You have strong ESP Powers.”,150,30, canvas);
}
else // red is not the color of the invisible square
{
new Text( “WRONG!.”,150,30, canvas);
}
}
else if ( YellowSquare.contains(pt) ) // Check to see if the yellow square was clicked
{
// yellow was clicked
new Text ( “You got vibes that the box was YELLOW”, 150,10,canvas);
// Now check to see if yellow is the color of the invisible box?
if ( InvisibleSquare.getColor() == Color.YELLOW)
{
new Text( “And it was YELLOW! You have strong ESP Powers.”,150,30, canvas);
}
else // yellow is not the color of the invisible square
{
new Text( “WRONG!.”,150,30, canvas);
}
}
(and so on)
When the mouse exits:
Clear the canvas()
And start over (i.e. copy and paste most of what you did in begin()