-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvader.java
More file actions
69 lines (62 loc) · 1.92 KB
/
Copy pathInvader.java
File metadata and controls
69 lines (62 loc) · 1.92 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* An Invader. The supposed bad guys. They are very simple.
*/
public class Invader {
/* An enemy looks like this:
*
*
* * *
* * *
* ***********
* *** *** ***
* *****************
* *****************
* * *********** *
* * * * *
* *** ***
*
*/
//very few variables.
private int coordinates[][];
private int hitPoints;
private boolean dead;
public Invader(int i, int j) {
//describes the shape of the invader.
int[][] temp = {
{i+4,j},{i-4,j},
{i+3,j+1},{i-3,j+1},
{i-5,j+2},{i-4,j+2},{i-3,j+2},{i-2,j+2},{i-1,j+2},{i,j+2},
{i+5,j+2},{i+4,j+2},{i+3,j+2},{i+2,j+2},{i+1,j+2},
{i-6,j+3},{i-5,j+3},{i-4,j+3},{i-1,j+3},{i,j+3},
{i+6,j+3},{i+5,j+3},{i+4,j+3},{i+1,j+3},
{i-8,j+4},{i-7,j+4},{i-6,j+4},{i-5,j+4},{i-4,j+4},{i-3,j+4},{i-2,j+4},{i-1,j+4},{i,j+4},
{i+8,j+4},{i+7,j+4},{i+6,j+4},{i+5,j+4},{i+4,j+4},{i+3,j+4},{i+2,j+4},{i+1,j+4},
{i-8,j+5},{i-7,j+5},{i-6,j+5},{i-5,j+5},{i-4,j+5},{i-3,j+5},{i-2,j+5},{i-1,j+5},{i,j+5},
{i+8,j+5},{i+7,j+5},{i+6,j+5},{i+5,j+5},{i+4,j+5},{i+3,j+5},{i+2,j+5},{i+1,j+5},
{i-8,j+6},{i-5,j+6},{i-4,j+6},{i-3,j+6},{i-2,j+6},{i-1,j+6},{i,j+6},
{i+8,j+6},{i+5,j+6},{i+4,j+6},{i+3,j+6},{i+2,j+6},{i+1,j+6},
{i-8,j+7},{i-5,j+7},{i+8,j+7},{i+5,j+7},
{i-4,j+8},{i-3,j+8},{i-2,j+8},
{i+4,j+8},{i+3,j+8},{i+2,j+8}
};
coordinates = temp;
dead = false;
hitPoints = Space.INV_HP;
}
public int[][] getCoordinates() {return coordinates;}
public boolean dead() {return dead;}
public int bottom() {return coordinates[coordinates.length-1][1];}
//probably not going to follow through with this idea. doesn't help with efficiency.
public int[][] getHitCoordinates() {
return null;
}
public void move() {
for (int[] coord: coordinates) {
coord[1] += Space.INV_SPEED;
}
}
public void hit() {
hitPoints--;
if (hitPoints <= 0) {dead = true;}
}
}