Jump to content

Drawing tiles around entities


Butters

Recommended Posts

Howdy ho,

Was wondering how you guys draw fancy stuff around entities, say monsters?

Atm using something as simple as

g2.draw(npc.getPosition().getPolygon(getBot());

Naturally, this draws a square of 1x1 around the entity.

Say the entity takes up two grids. Anyway to find that out and draw it?

Thanks

Link to comment
Share on other sites

The position you get is anchored South-West, so if the entity is 2x2, your position will be the SW corner.
Use the entity size along with the anchor position of the entity to construct the area or polygon.

Entity has the getSizeX and getSizeY methods used to get the tile dimensions of an entity, tho unfortunately it's only properly implemented in the RS2Object related entities. If you want to do it for NPCs you will either need to hardcode the size, or do some hacky calculations with the model

  • Like 1
Link to comment
Share on other sites

13 minutes ago, FrostBug said:

The position you get is anchored South-West, so if the entity is 2x2, your position will be the SW corner.
Use the entity size along with the anchor position of the entity to construct the area or polygon.

Entity has the getSizeX and getSizeY methods used to get the tile dimensions of an entity, tho unfortunately it's only properly implemented in the RS2Object related entities. If you want to do it for NPCs you will either need to hardcode the size, or do some hacky calculations with the model

Thanks, had a hunch it won't be easy.

Tried getSizeX() and getSizeY() (both deprecated) on npcs earlier but they returned wrong values.

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...