-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTitleBackground.java
More file actions
executable file
·143 lines (121 loc) · 3.59 KB
/
Copy pathTitleBackground.java
File metadata and controls
executable file
·143 lines (121 loc) · 3.59 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class TitleBackground here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TitleBackground extends World
{
/**
* Constructor for objects of class TitleBackground.
*
*/
public TitleBackground()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(640, 480, 1);
prepare();
Greenfoot.start();
}
@Override
public void act()
{
/*
try
{
MouseInfo mi = Greenfoot.getMouseInfo();
if(mi.getClickCount() > 0)
{
Greenfoot.setWorld(new Background());
}
}
catch (Exception e)
{
}
*/
if (Greenfoot.mouseClicked(null))
{
MouseInfo mouse = Greenfoot.getMouseInfo();
//find out which one is selected
List<DifficultySelection>ds = getObjects(DifficultySelection.class);
int setting = 0;
int board = 1;
for(DifficultySelection d : ds)
{
if(d.active)
{
setting = d.selection;
}
}
List<BoardSelection>bs = getObjects(BoardSelection.class);
for(BoardSelection b : bs)
{
if(b.active)
{
board = b.selection;
}
}
switch(board)
{
case 2:
Greenfoot.setWorld(new VolcanoBackground(setting));
break;
default:
Greenfoot.setWorld(new Background(setting));
break;
}
}
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
TitlePlaque titleplaque = new TitlePlaque();
addObject(titleplaque, 299, 199);
int x = -20;
int i = 1;
int y = /*261*/ 244;
DifficultySelection difficultyselection = new DifficultySelection();
addObject(difficultyselection, 72 + x, y);
difficultyselection.selection = i;
difficultyselection.setSelected();
x += 50;
i++;
difficultyselection = new DifficultySelection();
addObject(difficultyselection, 72 + x, y);
difficultyselection.selection = i;
x += 50;
i++;
difficultyselection = new DifficultySelection();
addObject(difficultyselection, 72 + x, y);
difficultyselection.selection = i;
x += 50;
i++;
difficultyselection = new DifficultySelection();
addObject(difficultyselection, 72 + x, y);
difficultyselection.selection = i;
x += 50;
i++;
difficultyselection = new DifficultySelection();
addObject(difficultyselection, 72 + x, y);
difficultyselection.selection = i;
MouseFollower mousefollower = new MouseFollower();
addObject(mousefollower, 72, 267);
x = -20;
i = 1;
y = 426;
BoardSelection boardselection = new BoardSelection();
addObject(boardselection, 72 + x, y);
boardselection.selection = i++;
boardselection.setSelected();
x += 50;
boardselection = new BoardSelection();
addObject(boardselection, 72 + x, y);
boardselection.selection = i++;
x += 50;
}
}