Howdy…
I have really enjoyed all the dialogue so far with the questions and answers to my questions. This is an awesome community.
Today, I seem to be having a possible rounding issue with translating mousexy coordinates back to the exact isometric tile. I use two functions:
public RPGUtil.point ScreenToIsoPos(int screenX, int screenY)
{
//System.out.printf("@AY:AX = %d:%d\n",screenY,screenX);
float isoX = (((float)screenX) / ((float)this.terrain_width / 2.0f) + ((float)screenY) / ((float)this.terrain_height / 2.0f)) / 2.0f;
float isoY = (((float)screenY) / ((float)this.terrain_height / 2.0f) - ((float)screenX) / ((float)this.terrain_width / 2.0f)) / 2.0f;
//System.out.printf("@isoY:isoX = %d:%d\n",isoY,isoX);
return new RPGUtil.point((short)Math.floor(isoX), (short)(Math.floor(isoY)));
}
I have tried floor() and round() and it does the same thing.
public RPGUtil.point VirtualScreenToIsoPos(int screenX, int screenY)
{
Point xy = new Point(screenX,screenY);
xy.x-=(short)(this.vp_startX)+this.terrain_width/2;
xy.y-=(short)(this.vp_startY)+this.terrain_height/2;
return this.ScreenToIsoPos(xy.x, xy.y);
}
The issue seems to be if the mouse is toward the edges of the tile it should be on, it hops over to the adjacent tile.
Any one else fixed this issue?