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.

Icon sizes

I have a problem with rmvx. I got myself an icon sheet that is 436x360 and has 16x16 icons. Since vx's default Icon size is 24x24 I can't seem to get mine to display properly. I found this script in Window_Base that lets me change around the numbers.
Code:
def draw_icon(icon_index, x, y, enabled = true)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  end

I have tried different combinations and they seem to change the way the icons are displayed, but since I don't know what the numbers stand for I can't seem to find the right combo. Any ideas?
 

khmp

Sponsor

The problem is with how you are generating the rectangle around the icon on the icon sheet.

rect = Rect.new(icon_index % per_row * width, icon_index / per_col * height, width, height)

per_row : the amount of icons you have per row.
per_col : the amount of icons you have per column.
width : the width of the icon.
height : the height of the icon.

Neither 436 or 360 is divisible by 16. 432x352 is divisible by 16. You will have a problem there. You can't grab fractions of a pixel. So you might just have a problem with the icon sheet rather than the math.

Good luck with it tavoeltav! :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