Jump to content

getting position


Joseph

Recommended Posts


public Position getPositionUnderMouse(Point mousePosition) {

for(int x = 0; x < 104; x++) {

for(int y = 0; y < 104; y++) {

Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());

if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {

return pos;

}

}

}

return null;

}

Edited by Soldtodie
Link to comment
Share on other sites

	public Position getPositionUnderMouse(Point mousePosition) {
		
		for(int x = 0; x < 104; x++) {
			for(int y = 0; y < 104; y++) {
				Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());
				if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {
					return pos;
				}
			}
		}
		
		return null;
	}

don't check all the tiles in the region, just get the tiles around the local player and check them (iirc the landscape only draws max 25 tiles from the cameras location)

Link to comment
Share on other sites

	public Position getPositionUnderMouse(Point mousePosition) {
		
		for(int x = 0; x < 104; x++) {
			for(int y = 0; y < 104; y++) {
				Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());
				if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {
					return pos;
				}
			}
		}
		
		return null;
	}

 

If you use this, make sure you only call this method when clicking.

Not the kind of method you want to call every couple of ms.

Link to comment
Share on other sites

	public Position getPositionUnderMouse(Point mousePosition) {
		
		for(int x = 0; x < 104; x++) {
			for(int y = 0; y < 104; y++) {
				Position pos = new Position(getMap().getBaseX()+x, getMap().getBaseY()+y, getMap().getPlane());
				if(pos.isVisible(getBot()) && pos.getPolygon(getBot()).contains(mousePosition)) {
					return pos;
				}
			}
		}
		
		return null;
	}

thanks for this you gave me the idea.

 

don't check all the tiles in the region, just get the tiles around the local player and check them (iirc the landscape only draws max 25 tiles from the cameras location)

thats exactly what im going to do. Thanks for the info

 

If you use this, make sure you only call this method when clicking.

Not the kind of method you want to call every couple of ms.

i want it to be like the hover  debug where it still me the current tile.

 

Entity hover debug i think

i want the api version

 

mouse.getPosition() unless that's not what you wanted.

   

Unless this gets the x/y of where the mouse is on the osbot client and not what's under the mouse, but I was under the impression that this gets the in game cords.

that returns a point the x and y of the mouse position

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...