-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBulletGun.java
More file actions
35 lines (30 loc) · 1.1 KB
/
BulletGun.java
File metadata and controls
35 lines (30 loc) · 1.1 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
public class BulletGun extends Weapon {
private BulletGun() {}
public BulletGun(SpaceObj owner, int reloadTime, double ammo,
double velocity, int ttl, int damage, double mass,
boolean friendlyFire, boolean isTurret) {
this.owner = owner;
setAmmo(ammo);
setReloadTime(reloadTime);
reloadProgress = getReloadTime();
setVelocity(velocity);
setTTL(ttl);
this.damage = damage;
setMass(mass);
this.friendlyFire = friendlyFire;
this.isTurret = isTurret;
}
public static Weapon newDefaultWeapon(SpaceObj s) {
return new BulletGun(s, 60, Double.POSITIVE_INFINITY, 3, 60, 10, 0.5, false, false);
}
public Projectile generate() {
++reloadProgress;
if (owner.firing && reloadProgress > getReloadTime()) {
reloadProgress = 0;
return new Bullet(owner.x, owner.y, owner.dx, owner.dy,
owner.angle, owner.shipID, getVelocity(), getTTL(),
damage, getMass(), friendlyFire);
}
return new ProjectileBlank();
}
}