-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBomb.java
44 lines (43 loc) · 1.32 KB
/
Bomb.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
import greenfoot.*;
/**
* Write a description of class Bomb here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bomb extends Projectiles
{
public void act()
{
if(isTouching(Bullet.class)){
Explosion explosion = new Explosion();
getWorld().addObject(explosion, getX(),getY());
removeTouching(Bullet.class);
World myWorld = getWorld();
BG2 bg2 = (BG2)myWorld;
Counter counter = bg2.getCounter();
counter.addScore();
getWorld().removeObject(this);
return;
}
setLocation(getX(), getY() + 2);
setRotation(30);
if(isAtEdge() == true){
Explosion explosion = new Explosion();
getWorld().addObject(explosion, getX(),getY() - 3);
getWorld().removeObject(this);
return;
}
if(isTouching(IronMan.class)){
Explosion explosion = new Explosion();
getWorld().addObject(explosion, getX(),getY() - 3);
}
if(isTouching(Enemy2.class)){
Explosion explode = new Explosion();
getWorld().addObject(explode, getX(), getY());
removeTouching(Enemy2.class);
getWorld().removeObject(this);
return;
}
}
}