-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMainMenu.java
67 lines (55 loc) · 1.9 KB
/
MainMenu.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MainMenu extends World
{
Hitbox hitbox = new Hitbox();
GreenfootSound menutheme = new GreenfootSound("menutheme.mp3");
public MainMenu(GreenfootSound menutheme)
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(576, 430, 1, false);
addObject(hitbox,0,0);
addObject(new Start(), 412, 132);
addObject(new More(), 398, 224);
addObject(new Bush(), 459, 394);
addObject(new Achievements(), 155, 380);
addObject(new SaveBlock(), 150, 175);
this.menutheme = menutheme;
Greenfoot.setSpeed(50);
}
public void act() {
if (Greenfoot.isKeyDown("1")) {
menutheme.stop();
Greenfoot.setWorld(new Intro());
} else if (Greenfoot.isKeyDown("2")) {
menutheme.stop();
Greenfoot.setWorld(new IntroLevel1());
} else if (Greenfoot.isKeyDown("3")) {
menutheme.stop();
Greenfoot.setWorld(new IntroLevel2());
} else if (Greenfoot.isKeyDown("4")) {
menutheme.stop();
Greenfoot.setWorld(new IntroLevel3());
}
}
public void started() {
if (!menutheme.isPlaying()) {
menutheme.setVolume(70);
menutheme.playLoop();
}
}
public void stopped() {
menutheme.pause();
}
public void moveHitbox() {
MouseInfo mouse = Greenfoot.getMouseInfo();
if (mouse != null) {
hitbox.setLocation(mouse.getX(), mouse.getY());
}
}
}