I am used to coding in PHP but I am not really proficient with Java and this has been a problem for some time now. I expect it to be a fairly easy solution, however I cannot
1) Instead of an array you could use a Map
or Map
, which would of course allow negative indexes
2) If you know the dimensions of your world from the start you could just modify your getter to allow the API to accept negatives and [linearly] transform them into positives. So for example if your world is 100x1000 tiles and you want (-5,-100), you would have WorldMap.getTile(-5,-100)
which would translate to return tileArray[x+mapWidth/2][y+mapHeight/2];
which is (45,400)