-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDobranowskiBullets.java
83 lines (70 loc) · 1.62 KB
/
DobranowskiBullets.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//� A+ Computer Science
//www.apluscompsci.com
//Name - Patrick Dobranowski
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import javax.imageio.ImageIO;
import java.util.ArrayList;
import java.util.List;
//contains methods for controlling the amount of ammo available to the player
public class DobranowskiBullets {
//list of all ammo available to the player
private ArrayList<DobranowskiAmmo> ammo;
//initializes ammo list with size of 0 initially
public DobranowskiBullets() {
ammo = new ArrayList<DobranowskiAmmo>(0);
}
//add to list of ammo
public void add(DobranowskiAmmo a) {
ammo.add(a);
}
public void drawEmAll(Graphics window) {
if (ammo.size() > 0) {
for (DobranowskiAmmo a : ammo) {
a.draw(window);
}
}
}
public void moveEmAll() {
if (ammo.size() > 0) {
for (DobranowskiAmmo a : ammo) {
a.move("UP");
}
}
}
//remove used ammo from list by checking whether it is "alive"
public void cleanEmUp() {
if (ammo.size() > 0) {
for (int i = 0; i < ammo.size(); i++) {
if (!ammo.get(i).isAlive()) {
ammo.remove(i);
i = 0;
}
}
}
}
//getter methods for specific ammo, the list of ammo, and properties of the ammo list
public DobranowskiAmmo getAmmo(int pos) {
return ammo.get(pos);
}
public List<DobranowskiAmmo> getList() {
return ammo;
}
public int getSize() {
return ammo.size();
}
//at end of game cause all ammo to cease moving
public void end()
{
if (ammo.size() > 0) {
for (int i = 0; i < ammo.size(); i++) {
ammo.get(i).setSpeed(0);
}
}
}
public String toString() {
return "";
}
}