-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShield.java
More file actions
34 lines (31 loc) · 929 Bytes
/
Shield.java
File metadata and controls
34 lines (31 loc) · 929 Bytes
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
//Shield.java
//Spencer Trepanier
//Shield class creates a shield object.
//Shields are an arraylist of rectangles, each vulnerable to enemy/ufo or player bullets
import java.awt.*;
import java.awt.geom.*;
import java.util.*;
public class Shield{
public static int x,y,w,l;
public Rectangle sRect;
public ArrayList<Rectangle> shieldSquares;
public Shield(int xx, int ww, int ll) {
x = xx;
y = 450;
w = ww;
l = ll;
shieldSquares = new ArrayList<Rectangle>();
for(int i=0; i<12; i++){ //builds the shield
for(int j=0; j<8; j++){
shieldSquares.add(new Rectangle(x+i*5,y+j*5,w/5,l/5));
}
}
sRect = new Rectangle(x,y,w,l);
}
public void draw(Graphics g){ //draws the shield
g.setColor(Color.GREEN);
for(Rectangle sS:shieldSquares){ //draws each individual square
g.fillRect((int)sS.getX(),(int)sS.getY(),(int)sS.getWidth(),(int)sS.getHeight());
}
}
}