-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
31 lines (26 loc) · 1002 Bytes
/
Copy pathMainMenu.java
File metadata and controls
31 lines (26 loc) · 1002 Bytes
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* This class represents the Main Menu screen.
* It contains buttons to start the game, view help, and exit.
*
@authors (Rupert & Raymond Van Niekerk)
* @student Numbers (222894237 & 221154469)
* @version (1)
*/
public class MainMenu extends World {
public MainMenu() {
super(800, 600, 1);
prepare();
}
private void prepare() {
// Create and add the start button to the world
Button startButton = new Button("Start");
addObject(startButton, getWidth() / 2, getHeight() / 2 + 50);
// Create and add the help button to the world
Button helpButton = new Button("Help");
addObject(helpButton, getWidth() / 2, getHeight() / 2 + 100);
// Create and add the exit button to the world
Button exitButton = new Button("Exit");
addObject(exitButton, getWidth() / 2, getHeight() / 2 + 150);
}
}