-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCombatPix.java
63 lines (58 loc) · 1.23 KB
/
CombatPix.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
/**
* CombatPix Class
* The large grouping of Pix overcomes the small
* Still working on implementation:
* - How do we count the Pix objects in a cluster?
* - How do we keep the algorithm fast?
* @author Nic Manoogian
*/
// import java.util.ArrayList;
public class CombatPix extends NonconformingPix
{
// Possibly keep track of strength at the edges
private int strength;
// Possibly keep track of children
// private ArrayList<CombatPix> children;
public CombatPix()
{
super();
strength = 0;
}
public CombatPix(int r, int g, int b)
{
super(r,g,b);
strength = 0;
}
public void setStrength(int s)
{
strength = s;
}
public int getStrength()
{
return strength;
}
/**
* Disintegrate if not interacting with another ScaredPix
*/
public void interact(Pix p)
{
if (p instanceof CombatPix && !equal(p))
{
if (((CombatPix)p).getStrength() > getStrength())
{
setPix(255,255,255);
strength--;
}
}
}
/**
* Copies a Pix to a new location and increases strength
*/
public void movePixel(Pix[][] grid, int ix, int iy, int x, int y)
{
Spawner.spawnXY( grid[ix][iy].getClass(), x, y );
grid[x][y].setPix(grid[ix][iy]);
strength++;
((CombatPix)grid[x][y]).setStrength(strength);
}
}