Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help with Icon Bars

Hey everybody, below follows a method of "Icon Bars." It works perfectly under RMVX and I would like to know how do I get the "HP" and "MP" the character is represented by icons (using this method to draw the bars).

Displaying Icon Bars on a window common
http://i433.photobucket.com/albums/qq55 ... bars_1.png[/img]

Example of how to be on HP and/or MP's character:
http://i433.photobucket.com/albums/qq55 ... bars_2.png[/img]

Code of Icon Bar:

Code:
class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Draw icon bar
  #     x      : draw spot x-coordinate
  #     y      : draw spot y-coordinate
  #     value  : number of half-icons to draw filled
  #     max    : number of half-icons to draw total
  #     filled : name of icon used as filled
  #     empty  : name of icon used as empty    
  #-----------------------------------------------------------------------
  def draw_icon_bar(x, y, value, max, filled = 'Filled', empty = 'Empty')
    return if self.contents == nil
    filled_icon = Cache.picture(filled)
    empty_icon = Cache.picture(empty)
    for i in 0...value
      icon_x = (i / 2) * 32 + ((i % 2) * 12) + x
      if i % 2 == 1
        rectangle = Rect.new(12, 0, 12, 24)
      else
        rectangle = Rect.new(0, 0, 12, 24)
      end
      self.contents.blt(icon_x, y + 4, filled_icon, rectangle, 255)
    end
    for i in value...max
      icon_x = (i / 2) * 32 + ((i % 2) * 12) + x
      if i % 2 == 1
        rectangle = Rect.new(12, 0, 12, 24)
      else
        rectangle = Rect.new(0, 0, 12, 24)
      end
      self.contents.blt(icon_x, y + 4, empty_icon, rectangle, 255)
    end
  end
end

Thank you for any help. :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top