You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//2. set the mouse pointer to the start of your maze using:
28
-
//new Robot().mouseMove(xPosition, yPosition)
29
+
newRobot().mouseMove(17,303);
29
30
30
31
//3. add a mouse motion listener using:
31
-
//addMouseMotionListener(this)
32
+
addMouseMotionListener(this);
32
33
33
34
}
34
35
@@ -38,27 +39,35 @@ public void mouseMoved(MouseEvent e) {
38
39
intmouseY = e.getY();
39
40
intmouseColor = maze.getRGB(mouseX, mouseY);
40
41
//4. print the mouseColor variable to see what color the mouse is touching
42
+
System.out.println(mouseColor);
41
43
42
44
//5. make a variable to hold the background color.
45
+
intbackgroundColor = -1230536;
46
+
intfinishColor = -16711699;
43
47
44
48
//6. if the mouse falls off the path (if it is on the background)
45
-
49
+
if(mouseColor==backgroundColor){
50
+
scare();
51
+
}
46
52
// call the scare method
47
53
48
54
//10. if the mouse is on the end color
49
-
55
+
if(mouseColor==finishColor){
56
+
JOptionPane.showMessageDialog(null, "congrats. you finished the SCARY MAZE!");
57
+
}
50
58
// pop up a message to tell them they won
51
59
52
60
}
53
61
54
62
privatevoidscare() {
55
63
System.out.println("BOO!");
56
64
//7. find a scary sound and put it in the day5 package where you put your maze picture. You can find a sound on freesound.org. Log in as leagueofamazing/code4life.
0 commit comments