Skip to content

Commit 10e3a51

Browse files
committed
Edited documentation
1 parent 1606303 commit 10e3a51

File tree

6 files changed

+54
-6
lines changed

6 files changed

+54
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.class
22
testing
33
doc
4+
Pixelife.sublime*

ConformingPix.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Class ConformingPix
3+
* @author Nic Manoogian <[email protected]>
4+
* @author Mike Lyons
5+
*/
16
public class ConformingPix extends Pix
27
{
38

@@ -10,6 +15,6 @@ public ConformingPix()
1015

1116
public void interact(Pix p)
1217
{
13-
18+
1419
}
1520
}

DirectedPix.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Class Directed Pix
3+
* Pixel only move in one direction
4+
* @author Nic Manoogian <[email protected]>
5+
* @author Mike Lyons
6+
*/
17

28
public class DirectedPix extends Pix
39
{
@@ -20,7 +26,9 @@ public void setDir(int dir)
2026
}
2127

2228
/**
23-
* Updates this specific pix, moving it in it's direction
29+
* Updates specific Pix, moving it in it's direction using its location
30+
* @param i x location
31+
* @param j y location
2432
*/
2533
public void update(int i, int j)
2634
{

Pix.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ public void trans(Pix[][] grid, int ix, int iy, int x, int y)
286286
}
287287

288288
/**
289-
* Updates this specific pix, moving it randomly
289+
* Updates this specific Pix, choosing a direction and moving it randomly
290+
* @param i x location
291+
* @param j y location
290292
*/
291293
public void update(int i, int j)
292294
{
@@ -297,6 +299,10 @@ public void update(int i, int j)
297299

298300
/**
299301
* Moves the direction given (N S E W)
302+
* @param grid PixGrid object
303+
* @param dirNum direction to move
304+
* @param i x location of pixel
305+
* @param j y location of pixel
300306
*/
301307
public void moveDir(Pix[][] grid, int dirNum, int i, int j)
302308
{

Pixelife.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ public Pixelife(int w, int h, int n)
3535
height = h;
3636

3737
myGrid = new PixGrid(w, h, n);
38-
//line_spawner = new Spawner(DirectedPix.class, myGrid, 0, h/2);
39-
spawner = new Spawner(PulsePix.class, myGrid);
38+
Spawner vline_spawner = new Spawner(DirectedPix.class, myGrid, 2, h/2);
39+
vline_spawner.spawn(5);
40+
Spawner hline_spawner = new Spawner(DirectedPix.class, myGrid, 0, h/2);
41+
hline_spawner.spawn(5);
42+
spawner = new Spawner(NonconformingPix.class, myGrid);
4043
spawner.spawn(10);
4144
}
4245

Spawner.java

+26-1
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,22 @@ public Spawner(Class<?> c)
5656
/**
5757
* Creates a Spawner that will spawn a given class to a given grid
5858
* @param c Class to spawn (PulsePix.class)
59-
* @param grid pixgrid112
59+
* @param grid PixGrid object
6060
*/
6161
public Spawner(Class<?> c, PixGrid grid)
6262
{
6363
this();
6464
this.spawnClass = c;
6565
this.grid = grid;
6666
}
67+
68+
/**
69+
* Creates a Spawner with a give class, grid and x and y velocities
70+
* @param c Class to spawn
71+
* @param grid PixGrid object
72+
* @param dx x velocity
73+
* @param dy y velocity
74+
*/
6775
public Spawner(Class<?> c, PixGrid grid, int dx, int dy)
6876
{
6977
this(c, grid);
@@ -74,6 +82,9 @@ public Spawner(Class<?> c, PixGrid grid, int dx, int dy)
7482
this.defaultY = dy;
7583
}
7684

85+
/**
86+
* Spawns random instances of the spawn class to the grid
87+
*/
7788
public void spawn()
7889
{
7990
if(Pix.class.isAssignableFrom(spawnClass))
@@ -97,6 +108,11 @@ public void spawn()
97108
System.out.println("Class not found");
98109
}
99110
}
111+
112+
/**
113+
* Spawns a number of instances of the spawn class to the grid
114+
* @param num number of instances to spawn
115+
*/
100116
public void spawn(int num)
101117
{
102118
if(Pix.class.isAssignableFrom(spawnClass))
@@ -119,6 +135,12 @@ public void spawn(int num)
119135
}
120136
}
121137

138+
/**
139+
* Spawns a specific instance of a class to a specific x and y location
140+
* @param c class to spawn
141+
* @param x x location to spawn
142+
* @param y y location to spawn
143+
*/
122144
public static void spawnXY(Class<?> c, int x, int y)
123145
{
124146
if(Pix.class.isAssignableFrom(c))
@@ -135,6 +157,9 @@ public static void spawnXY(Class<?> c, int x, int y)
135157
}
136158
}
137159

160+
/**
161+
* Determines if a spawn is necessary, otherwise, increase counter
162+
*/
138163
public void update()
139164
{
140165
if( respawnMax != -1 )

0 commit comments

Comments
 (0)