Drawing GroundItems

Discussion in 'Developer Support' started by Geashaw, Feb 21, 2015.

  1. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,271
    Likes Received:
    217
    So I came up with the most idiot Saturday evening thought;

    Code (Text):
    1. GroundItem runes = GroundItems.newQuery().names("Air rune", "Law rune", "Nature rune").results().nearest();
    2.  
    3. if (runes != null) {
    4.     String s = runes.getDefinition().getName();
    5.     if (s != null) {
    6.         int x = runes.getModel().getPosition().getX();
    7.         int y = runes.getModel().getPosition().getY();
    8.         g.drawString("" + s, x, y);
    9.     }
    10. }
    What would I have to change to make it draw the name on the item. Perhaps drawing a rectangle as well :$
     
  2. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,396
    Likes Received:
    683
    Use getBounds instead of getModel. then just translate it by the appropriate x and y based on the bounds width and height
     
  3. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,271
    Likes Received:
    217
    I found that runes.getBounds() was not possible for someway. Perhaps because it's a GroundItem?
     
  4. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,396
    Likes Received:
    683
    Oooh derp i was thinking it was an inventory item. Okay so getModel.getBoundingRectangle?
     
  5. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,271
    Likes Received:
    217
    Right, though the GroundItem part should work for that right? And drawing the string name as well should then probably work.
     
  6. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,271
    Likes Received:
    217
    @Aidden it's not too bad ...

    [​IMG]

    Any suggestions? :)
     
  7. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,951
    Likes Received:
    861
    getModelBounds should return a renderable rectangular prism,
    possibly reducing text size and centering it?
     
  8. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,271
    Likes Received:
    217
    Decided to only draw item names since those rectangles were really ugly...

    [​IMG]
     
  9. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,951
    Likes Received:
    861
    Hmmm, the boxes usually don't seem too bad, the rectangles however do look pretty derp
     

Share This Page

Loading...