1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Drawing GroundItems

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

  1. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,429
    Likes Received:
    252
    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 Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,482
    Likes Received:
    990
    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,429
    Likes Received:
    252
    I found that runes.getBounds() was not possible for someway. Perhaps because it's a GroundItem?
     
  4. Aidden

    Aidden Author of MaxiBots

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

    Joined:
    Jan 8, 2015
    Messages:
    1,429
    Likes Received:
    252
    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,429
    Likes Received:
    252
    @Aidden it's not too bad ...

    [​IMG]

    Any suggestions? :)
     
  7. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,198
    Likes Received:
    1,041
    getModelBounds should return a renderable rectangular prism,
    possibly reducing text size and centering it?
     
  8. Geashaw

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

    [​IMG]
     
  9. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,198
    Likes Received:
    1,041
    Hmmm, the boxes usually don't seem too bad, the rectangles however do look pretty derp
     

Share This Page

Loading...