-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplosion.java
45 lines (39 loc) · 1.2 KB
/
Explosion.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.ArrayList;
/**
* Write a description of class Explosion here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Explosion extends animatedObject
{
public GreenfootImage[] explosion;
public ArrayList<Zombie> zombies;
/**
* Act - do whatever the Explosion wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Explosion(ArrayList<Zombie> zombies) {
this.zombies = zombies;
explosion = importSprites("spudow",8);
}
public void addedToWorld(World world) {
AudioPlayer.play(80, "potato_mine.mp3");
for (int i = zombies.size()-1; i >= 0; i--) {
if (Math.abs(zombies.get(i).getX() - getX()) < 44) {
zombies.get(i).takeDmg(900);
}
}
}
public void act()
{
if (frame <= 8) {
animate(explosion, 100L, false);
} else {
getWorld().removeObject(this);
return;
}
// Add your action code here.
}
}