-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemyFire.java
More file actions
49 lines (44 loc) · 1.11 KB
/
EnemyFire.java
File metadata and controls
49 lines (44 loc) · 1.11 KB
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
import greenfoot.*;
/**
* Enemies' bullet
*
* @author Barry Al-Jawari, Betim Goxhuli, Edi Imamovic, James Lay
*/
public class EnemyFire extends Enemies
{
private int direction, speed;
public EnemyFire(int dir)
{
direction = dir;
speed = -15;
}
public void act()
{
setRotation(direction);
move(speed);
checkCollision();
}
public void Remove()
{
if(atWorldEdge() && this!=null){
World world = getWorld();
world.removeObject(this);
}
}
private void checkCollision()
{
Actor Player = getOneIntersectingObject(Player.class);
if(atWorldEdge()){
World world = getWorld();
world.removeObject(this);
}
else if (Player !=null && this!=null)
{
World world = getWorld();
world.addObject(new Boom(), getX(), getY());
world.addObject(new ButtonBack(), 100, 100);
world.removeObject(this);
world.removeObject(Player);
}
}
}