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