Game Development Reference
In-Depth Information
The CellUtil class
The
CellUtil
class is used in the
Flowing water with cellular automata
recipe of
public class CellUtil {
private static int[][] directions = new
int[][]{{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}};
public static int getDirection(int x, int y){
witch(x){
case 1:
switch(y){
case -1:
return 1;
case 0:
return 2;
case 1:
return 3;
}
break;
case -1:
switch(y){
case -1:
return 7;
case 0:
return 6;
case 1:
return 5;
}
break;
case 0:
switch(y){
case -1:
return 0;
case 0:
return -1;
case 1: