//assumes all rotation is done void drawWorld(){ strokeWeight(2); // noStroke(); float startX = (BOXSIZE * BOXCOUNT)*-.5; float startY = (BOXSIZE * BOXCOUNT) * -.5; for(int x = 0; x < BOXCOUNT; x++){ for(int y = 0; y < BOXCOUNT; y++){ if(world[x][y]==EMPTY || world[x][y]==HEART){ noStroke();//stroke(128); fill(70,70,70); rect(startX+(x*BOXSIZE),startY+(y*BOXSIZE), BOXSIZE,BOXSIZE); } /*if(world[x][y] 0){ if(world[x][y] == 2) fill(255,200,200); //heart color rect(startX+(x*BOXSIZE),startY+(y*BOXSIZE), BOXSIZE,BOXSIZE); rect(startX+(x*BOXSIZE),startY+(y*BOXSIZE), BOXSIZE,BOXSIZE); }*/ } } } // note this kind of assumes WORLDSIZE = 19.... int[][] getWorld(){ return new int[][] {//FULL WORLD /* {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,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,0,0,1,0,1,1,1,1,0,1}, {1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,0,1}, {1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1}, {1,0,1,0,1,0,1,1,0,0,0,0,1,0,1,1,1,0,1}, {1,0,1,0,0,0,0,1,1,1,1,0,1,0,1,1,1,0,0}, {0,0,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1}, {1,0,0,0,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1}, {1,0,1,1,1,1,0,0,0,2,0,0,0,0,1,1,1,0,1}, {1,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1,1,1,1}, {1,1,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,1}, {1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,0}, {0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1}, {1,1,1,0,1,1,1,1,0,1,1,1,1,1,0,0,0,0,1}, {1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1}, {1,1,1,0,1,1,1,1,0,1,0,1,0,1,1,1,1,0,0}, {1,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1}, {1,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1}*/ }; } int[][] rotateWorldCW(int source[][]){ int [][] dest = new int[BOXCOUNT][BOXCOUNT]; for(int x = 0; x < BOXCOUNT; x++){ for(int y = 0; y < BOXCOUNT; y++){ dest[x][y] = source[y][(BOXCOUNT-1)-x]; } } return dest; } int[][] rotateWorldCCW(int source[][]){ int [][] dest = new int[BOXCOUNT][BOXCOUNT]; for(int x = 0; x < BOXCOUNT; x++){ for(int y = 0; y < BOXCOUNT; y++){ dest[x][y] = source[(BOXCOUNT-1)-y][x]; } } return dest; } int getWorldContentsSafely(int x, int y){ if(x < 0 || x >= BOXCOUNT || y < 0 || y >= BOXCOUNT){ return EMPTY; } return world[x][y]; } //blank and not directly in line at some point?? intXandY findABlankSquare(){ int x, y; do{ x = 2+int(random(BOXCOUNT-4)); y = 2+int(random(BOXCOUNT-4)); // println("trying "+x+" and "+y+" THERE IS "+world[x][y]); } while(world[x][y] != EMPTY); // println("!!!!ACCEPTUI "+x+" and "+y+" THERE IS "+world[x][y]); return new intXandY(x,y); } class intXandY { int x, y; intXandY(int px, int py){ x = px; y = py; } }