-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndScreenWon.java
More file actions
40 lines (32 loc) · 1.03 KB
/
EndScreenWon.java
File metadata and controls
40 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* End screen and score. Checks mouse input.
*/
public class EndScreenWon extends World {
public static GreenfootSound soundWon = new GreenfootSound("victory.mp3");
private int x = 0;
private int y = 0;
public EndScreenWon() {
super(550, 600, 1);
prepare();
}
public void prepare() {
Timer.timer = 0;
addObject(new Ending(), 400, 200);
}
public void act() {
soundWon.play();
MouseInfo mouse = Greenfoot.getMouseInfo();
if (mouse != null) {
x = mouse.getX();
y = mouse.getY();
if (Greenfoot.mouseClicked(null)) {
if (x > 390 && x < 550 && y > 515 && y < 550) {
Greenfoot.setWorld(new MainMenu());
} else if (x > 400 && x < 550 && y > 555 && y < 600) {
Greenfoot.setWorld(new Credits());
}
}
}
}
}