forked from TechHead27/EW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
56 lines (52 loc) · 1.66 KB
/
MainMenu.java
File metadata and controls
56 lines (52 loc) · 1.66 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
49
50
51
52
53
54
55
56
import greenfoot.*;
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MainMenu extends World
{
private static final int[][] options = {{170, 96}, {170, 200}, {170, 304}};
private Arrow selector;
private GreenfootSound bgm;
private MenuItem play = new MenuItem("images/buttons/button_play.png");
private MenuItem quit = new MenuItem("images/buttons/button_quit.png");;
private MenuItem credits = new MenuItem("images/buttons/button_credits.png");;
/**
* Constructor for objects of class MainMenu.
*
*/
public MainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
selector = new Arrow(options);
addObject(selector, 170, 96);
addObject(play, 300, 90);
addObject(quit, 300, 195);
addObject(credits, 300, 300);
bgm = new GreenfootSound("BGM/TitleScreen.mp3");
}
public void act()
{
bgm.playLoop();
if (Greenfoot.isKeyDown("enter"))
{
switch (selector.getSelection())
{
case 0: Greenfoot.setWorld(new ForestMap1());
bgm.stop();
break;
case 1: Greenfoot.stop();
bgm.stop();
break;
case 2: Greenfoot.setWorld(new Credits("images/credits/credits1.png"));
bgm.stop();
break;
default://never get here
break;
}
}
}
}