-
Notifications
You must be signed in to change notification settings - Fork 6
/
IntroLevel3.java
149 lines (122 loc) · 5.76 KB
/
IntroLevel3.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
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
144
145
146
147
148
149
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class IntroLevel3 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class IntroLevel3 extends World
{
public GreenfootSound CYS = new GreenfootSound("chooseyourseeds.mp3");
public int count = 0;
public int scrollSpeed = 4;
public int location = 0;
public boolean started = false;
public Zombie n = null;
public SeedPacket[] bank = {new SunflowerPacket(), new PeashooterPacket(), new WalnutPacket(), new PotatoPacket(), new RepeaterPacket(), new TwinSunflowerPacket()};
public SeedBank seedbank = new SeedBank(bank);
public Zombie[][] level3 = {
{null, n, null, new BasicZombie()},
{n},
{new BasicZombie(), new Buckethead(), new Buckethead(), new Buckethead(), null},
{new BasicZombie(),n,new Buckethead(),new Buckethead(),n,new BasicZombie()},
{n, new Conehead(), n, new Buckethead(),n,n,new BasicZombie(),n,n,n,new BasicZombie(),new BasicZombie()},
{new BasicZombie(),n,n,n,new Conehead(), n,n,n,n,n,n,n,n,n,new BasicZombie()},
{n},
{new BasicZombie(), new Conehead(), new Brickhead(), new BasicZombie(), new Conehead(), new BasicZombie(), new BasicZombie(), new Buckethead()},
{new BasicZombie(),n,n,new BasicZombie(),new BasicZombie()},
{n,n,new Buckethead(), n,n,n,n,new Buckethead()},
{new Conehead(), new Conehead(),new Buckethead(), new Conehead(),new Conehead()},
{new BasicZombie(), new Conehead(), new BasicZombie(), new BasicZombie(), new BasicZombie()},
{new Brickhead()},
{new Conehead(), new Buckethead(), new Buckethead(), new Conehead(), new Buckethead()},
{n},
{new BasicZombie(), new BasicZombie(), new BasicZombie(), new BasicZombie(), new BasicZombie()},
{n,n,n,new Brickhead(), new Brickhead()},
{new Conehead(), new Buckethead(), new Conehead()},
{n},
{new Buckethead(), new Buckethead(), new Buckethead(), new Buckethead(), new Buckethead()},
{new BasicZombie(), new BasicZombie(), new BasicZombie(), new BasicZombie(), new BasicZombie()},
{n, new Conehead()},
{n,n,n,n,new BasicZombie()},
{n},
{new BasicZombie(), new BasicZombie(),new BasicZombie(),new BasicZombie(),new BasicZombie()},
{new Conehead(),new Conehead(),new Conehead(),new Conehead(),new Conehead(), new Buckethead(),new Buckethead(),new Buckethead(),new Buckethead(),new Buckethead(), new Brickhead(),new Brickhead(),new Brickhead(),new Brickhead(),new Brickhead()},
{n},
{n,n,new Buckethead(), n,n,n,n,new Buckethead(),n,n,n,n,new Buckethead(),n,n,n,n,new Buckethead(), n,n,n,n,new Buckethead(),n,n,n,n,new Buckethead()}
};
public WaveManager level = new WaveManager(23500L, level3, 15000L, true, 7, 13, 19, 24, 27);
public IntroLevel3()
{
super(733, 430, 1, false);
addObject(new Basic(), 800, 200);
addObject(new Basic(), 920, 310);
addObject(new IdleCone(), 800, 110);
addObject(new IdleBucket(), 900, 100);
addObject(new IdleCone(), 890, 370);
addObject(new IdleBucket(), 822, 241);
addObject(new IdleBrickhead(), 890, 210);
addObject(new IdleBrickhead(), 850, 70);
addObject(new IdleBrickhead(), 824, 317);
CYS.setVolume(70);
}
public void act() {
if (!started) {
started = true;
CYS.playLoop();
}
count++;
bgScrollAnimate();
}
public void bgScrollAnimate()
{
if (count == 100 )
{
//removeObject(message);
}
if ( count > 100 && count < 160)
{
location -= scrollSpeed;
scrollBGimage(location);
}
else if (count > 350 && count < 410)
{
location += scrollSpeed;
scrollBGimage(location);
}
else if (count == 450) {
List<IdleZombie> idleZombie = getObjects(IdleZombie.class );
for ( IdleZombie zombie : idleZombie ) {
removeObject(zombie);
}
}
else if ( count == 500 )
{
List<IdleZombie> idleZombie = getObjects(IdleZombie.class );
for ( IdleZombie zombie : idleZombie ) {
removeObject(zombie);
}
Greenfoot.setWorld(new MyWorld(CYS,level, seedbank, new IntroLevel3(), new WinTwinsunflower()));
}
}
public void scrollBGimage(int offset)
{
GreenfootImage bg = getBackground();
GreenfootImage move = new GreenfootImage("lawn2.png");
bg.drawImage(move, offset, 0);
// get all objects and move them by the offset delta value
List<Actor> currentObjects = getObjects(null);
for ( Actor thisObject : currentObjects )
{
if ( count > 100 && count < 160)
{
thisObject.setLocation(thisObject.getX() - scrollSpeed , thisObject.getY() );
}
else if ( count > 350 && count < 410)
{
thisObject.setLocation(thisObject.getX() + scrollSpeed , thisObject.getY() );
} // end inner if/else
} // end for-each loop
}
}