//========================== class Terrain{ int w, h; int terrainScale, cellSize; Entity[][] groundEntity; int[][] CPUDist; int[][] wallBreakerCPUDist; float[][] shading; boolean[][] isPath, isCPU, isBoard; color pathColor, dmzColor, cpuColor; //--------------- Terrain(String filepath){ pathColor = color(0,96,128); dmzColor = color(32,128,32); cpuColor = color(128); PImage map = loadImage( filepath ); w = map.width; h = map.height; cellSize = 400/16; terrainScale = cellSize*w; groundEntity = new Entity[w][h]; shading = new float[w][h]; CPUDist = new int[w][h]; wallBreakerCPUDist = new int[w][h]; isPath = new boolean[w][h]; isCPU = new boolean[w][h]; isBoard = new boolean[w][h]; for(int x=0;x0 && gx0 && gy minDist+1 ){ CPUDist[x][y] = minDist+1; changing = true; } } } // separate loop for the distance matrix for wall-breaking enemies changing = true; while( changing ){ changing = false; for(int x=1;x minDist+1 ){ wallBreakerCPUDist[x][y] = minDist+1; changing = true; } } else if( isBoard[x][y] ) if( wallBreakerCPUDist[x][y] > minDist+4 ){ wallBreakerCPUDist[x][y] = minDist+4; changing = true; } } } } //--------------- void visualize(){ fill(dmzColor); noStroke(); float offset = -terrainScale/(2f*h); for(int x=0;x