0

I'm trying to write a simplified google maps programme using javafx classes. I've stored the image strings in a matrix of string. I then use button fields to trigger functions that move through the matrix to show the appropriate picture. If the neighbouring matrix element is null then the respective button is then hidden, so you can't walk through a wall.

forward = y+2
backwards  = y-2
left(90 degrees) = x-1
right = x+1

my problem is that in my program you can't keep clicking left or right and rotate through 360 degrees, 90 degrees at a time, you can only click left or right once. I had to make forward and backward y+-2 because the 'backwards view' picture is y+1. Is there a way I can say..

upon the first click of left button do x = x-1; upon the second click do y = x - 2; etc...

private button = Forwards;
private button = Backwards;
etc...
private ImageView = mainDisplay;

private int x = 10;
private int y = 10;
String[][] ImageURLs = new String[x][y];

//load images into matrix//
ImageURLs[0][0] = "....jpg";
ImageURLs[0][1] = "....jpg";
ImageURLs[0][2] = "0";

public void Forward(ActionEvent event) {
y = y+2;
x = x;
Image image = new Image(ImageURLs[x][y]);
//if ImageURLs[x][y+1] = null 
//hide button//
mainDisplay.setImage(image);
}
  • Please, write a [mcve] of your problem. This could be simplified with a integer matrix (in your example)... – AxelH Nov 21 '16 at 12:17
  • Possible duplicate of [How do you rotate a two dimensional array?](http://stackoverflow.com/questions/42519/how-do-you-rotate-a-two-dimensional-array) – AxelH Nov 21 '16 at 12:18
  • I'll check the java doc on 2d arrays and see if it can be rotated – Thomas Shemeld Nov 21 '16 at 12:26
  • PS : did you made any search ? [a another duplicate(http://stackoverflow.com/questions/26610309/java-rotating-array) – AxelH Nov 21 '16 at 12:33

0 Answers0