-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathIntroLevel2.java
133 lines (111 loc) · 4.65 KB
/
IntroLevel2.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
* Write a description of class IntroLevel2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class IntroLevel2 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()};
public SeedBank seedbank = new SeedBank(bank);
public Zombie[][] level2 = {
{null, n, null, new BasicZombie()},
{n},
{new BasicZombie(), null, null, null, null},
{n,n,new BasicZombie()},
{null, new BasicZombie(), new BasicZombie(), new BasicZombie()},
{new Conehead()},
{null, null, new Conehead(), null, null, n, new BasicZombie()},
{n},
{new BasicZombie(), new Buckethead(), new BasicZombie(), new Conehead(), new BasicZombie(), n,new BasicZombie()},
{n},
{new Conehead(), n, null, new BasicZombie(), null, null, new BasicZombie()},
{n,n,n, new Conehead(), null, new Buckethead(), new BasicZombie()},
{n, new Brickhead(), null, null, null},
{n,new BasicZombie(),new BasicZombie(), new BasicZombie(),new Conehead(), new BasicZombie(), n, new BasicZombie(), new BasicZombie()},
{null, new BasicZombie(), new Buckethead(), null, new Conehead(),n,n,new BasicZombie()},
{new BasicZombie(), new BasicZombie(), new BasicZombie(), new Brickhead(), new Conehead()},
{null, null, new Conehead(), null, null},
{n},
{new Brickhead(), new Conehead(), new Conehead(), new BasicZombie(), new BasicZombie(), new Buckethead(), null, new BasicZombie(), new Conehead(), new Brickhead()}
};
public WaveManager level = new WaveManager(23500L, level2, 15000L, true, 8, 18);
public IntroLevel2()
{
super(733, 430, 1, false);
addObject(new Basic(), 800, 200);
addObject(new IdleCone(), 900, 100);
addObject(new IdleCone(), 890, 370);
addObject(new Basic(), 822, 241);
addObject(new IdleBucket(), 890, 210);
addObject(new IdleBucket(), 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 IntroLevel2(), 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
}
}