But how do I do that?
I have changed the field into an array.
int[][] field = new int[cols][rows];
void drawgrid() {
for (int i = 0; i < field.length; i++) {
for (int j = 0; j < field[i].length; j++) {
How do I make a black diver that moves inside the array/grid?
Should i use:
int[][] diver = new int[cols][rows];
?
Or am I thinking wrong?
So I managed to make the diver set at the location of what I want using the same formula.
boolean[][] diver = new boolean[cols][rows];
void setdiver() {
int i = 0;
int j = 0;
diver[i][j] = true;
movementdiver(i);
}
However now that movementdiver is out of keypressed() how do I make it move?
I tried calling the function in setdiver as you can see however it does not respond to keypresses this way.
void movementdiver(int i) {
if (key == CODED) {
if (keyCode == DOWN) {
i = i + 1;
}
}