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.

HBGames

Hey all, um, quick novice question to ask. I'm trying to change a script for an HP bar so that it depletes vertically rather than horizontally and I'm having some trouble (mostly because I'm just playing around with it without any real understanding of what I'm doing)

Code:
  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh(actor)

    hppercent = actor.hp.to_f / actor.maxhp.to_f

    if hppercent > 0.66

      @sprites[1].bitmap = RPG::Cache.picture($game_set.hpbar_good)

    elsif hppercent > 0.33

      @sprites[1].bitmap = RPG::Cache.picture($game_set.hpbar_okay)

    else

      @sprites[1].bitmap = RPG::Cache.picture($game_set.hpbar_bad)

    end

    bar_width = (@sprites[1].bitmap.width.to_f * hppercent).round

    w = @sprites[1].bitmap.width-bar_width

    @sprites[1].src_rect = Rect.new(0, 0, bar_width, @sprites[1].bitmap.height)

  end

My solution was to change everything that related to 'width' and replace it with 'height' but all that achieved was a HP bar that doesn't change. Any ideas guys?

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