I have this grid:
I want to convert coordinates in this grid in greenfoot coordinates, the size of the world is
650 * 450. It needs to work with negative and positive values, I tried a few things but it doesn't seems to work

1 2 3 4 5 6 7 8 9 | // grid point (0, 0) is at greenfoot coordinate (originX, originY) int originX = 450 ; int originY = 400 ; // let us get a random point on the grid (gridX, gridY) int gridX = Greenfoot.getRandomNumber( 650 ) - originX; int gridY = originY - getHeight() + Greenfoot.getRandomNumber( 450 ); // now, covert to greenfoot coordinates (gfX, gfY) int gfX = originX + gridX; int gfY = originY - gridY; |