-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.java
56 lines (47 loc) · 1.37 KB
/
Bullet.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
import greenfoot.*;
/**
* Player's bullet
*
* @author Barry Al-Jawari, Betim Goxhuli, Edi Imamovic, James Lay
*/
public class Bullet extends Enemies
{
private int direction, speed;
private SimpleTimer timer = new SimpleTimer();
public Bullet(int dir)
{
direction = dir;
speed = 15;
}
public void act()
{
setRotation(direction);
move(speed);
checkCollision();
}
private void checkCollision()
{
Actor Enemy = getOneIntersectingObject(Enemy.class);
Actor EnemyFire = getOneIntersectingObject(EnemyFire.class);
if(atWorldEdge() && timer.millisElapsed()>600){
World world = getWorld();
world.removeObject(this);
}
if (Enemy !=null)
{
SingleplayerWorld Singleworld = (SingleplayerWorld) getWorld();
Singleworld.scoreCounter();
World world = getWorld();
world.addObject(new Boom(), getX(), getY());
world.removeObject(this);
world.removeObject(Enemy);
}
if (EnemyFire !=null && this!=null)
{
World world = getWorld();
world.addObject(new Boom(), getX(), getY());
world.removeObject(this);
world.removeObject(EnemyFire);
}
}
}