-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
48 lines (42 loc) · 1.46 KB
/
MainMenu.java
File metadata and controls
48 lines (42 loc) · 1.46 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
41
42
43
44
45
46
47
48
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* @author Dilanas Sabaliauskas 1 Grupe.
*/
/**
* MainMenu checks for mouse input to show controls, credits or start game.
*/
public class MainMenu extends SoundManager {
Quit quit = new Quit();
private int x = 0;
private int y = 0;
/**
* Constructor for objects of class MainMenu.
*/
public MainMenu() {
super(550, 600, 1);
EndScreenWon.soundWon.stop();
}
public void act() {
SoundManager.soundMenu.play();
MouseInfo mouse = Greenfoot.getMouseInfo();
if (mouse != null) {
x = mouse.getX();
y = mouse.getY();
if (Greenfoot.mouseClicked(null)) {
if (x > 350 && x < 510 && y > 400 && y < 530) {
PackLives.lives = 5;
Score.score = 0;
Timer.timer = 0;
SoundManager.soundMenu.stop();
Greenfoot.setWorld(new Level1());
} else if (x > 350 && x < 549 && y > 545 && y < 599) {
Greenfoot.setWorld(new Credits());
} else if (x > 0 && x < 238 && y > 545 && y < 599) {
Greenfoot.setWorld(new Controls());
} else if (x > 520 && x < 550 && y > 0 && y < 30) {
addObject(quit, getWidth()/2, getHeight()/2);
}
}
}
}
}