-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP2Border.java
82 lines (77 loc) · 2.56 KB
/
P2Border.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class P2Border here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class P2Border extends MenuElements
{
boolean chooseToggle = true;
public static boolean finalLockIn = false;
int timer = 0;
int selection = 1;
GreenfootSound next = new GreenfootSound("next.wav");
GreenfootSound select = new GreenfootSound("select.wav");
public P2Border(){
selection = 1;
finalLockIn = false;
chooseToggle = true;
timer = 0;
}
/**
* Act - do whatever the P2Border wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (chooseToggle) {
if (Greenfoot.isKeyDown ("down") && timer >= 10 && selection == 1) {
next.play();
setLocation (getX(), 225);
selection = 2;
timer = 0;
}
if (Greenfoot.isKeyDown ("down") && timer >= 10 && selection == 2) {
next.play();
setLocation (getX(), 326);
selection = 3;
timer = 0;
}
if (Greenfoot.isKeyDown ("up") && timer >= 10 && selection == 3) {
next.play();
setLocation (getX(), 225);
selection = 2;
timer = 0;
}
if (Greenfoot.isKeyDown ("up") && timer >= 10 && selection == 2) {
next.play();
setLocation (getX(), 124);
selection = 1;
timer = 0;
}
}
if (Greenfoot.isKeyDown ("1") && timer >= 10 && selection == 1) {
select.play();
chooseToggle = false;
finalLockIn = true;
setImage ("lockin_p2.png");
Background.spawnID2 = 1;
}
if (Greenfoot.isKeyDown ("1") && timer >= 10 && selection == 2) {
select.play();
chooseToggle = false;
finalLockIn = true;
setImage ("lockin_p2.png");
Background.spawnID2 = 2;
}
if (Greenfoot.isKeyDown ("1") && timer >= 10 && selection == 3) {
select.play();
chooseToggle = false;
finalLockIn = true;
setImage ("lockin_p2.png");
Background.spawnID2 = 3;
}
timer++;
}
}