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.

Hud that Shows an Icon = to that of the State the Player <Resolved>

Ok Basicly what I'm asking here is I have this Hud
Code:
#==============================================================================
# States_Hud
#------------------------------------------------------------------------------
# By: L0rdPh0enix
# Helped by: Khmp, Gando  
# 5/4/2008
#------------------------------------------------------------------------------
#==============================================================================
  HUD_SWITCH = 2

  class States_Hud < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize             
  #--------------------------------------------------------------------------
  def initialize
    super(441, 0, 85, 61)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 200
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
  end 
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map

  alias stateshud_main main
  alias stateshud_update update
  def main
    @stateshud = States_Hud.new
    stateshud_main
    @stateshud.dispose
  end
  def update
    if $game_switches[HUD_SWITCH]
      @stateshud.visible = true
    else
      @stateshud.visible = false
    end
    @stateshud.update
    stateshud_update
  end
end

Now the purpose of this Hud is it's a small part of a bigger User Interface system that. This piece is the housing for a Common Event that runs paralleled that's job is to monitor the main players States (i.e. Normal, Sleepy, Confused, ect.).
What I'd like to do is to cut out the middle man all together, removed the Common Event and the Hud Script Monitor the states and change the png it shows accordingly.

Thanks for the help in advance.
 
I hope it can help you :
Code:
  def refresh
    self.contents.clear
    if $game_actors[1].states[0] == nil
      icon_name = 'normal'
    else
      icon_name = $data_states[$game_actors[1].states[0]].name
    end
    
    bitmap = RPG::Cache.icon(icon_name)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(24 - cw / 2, 24 - ch, bitmap, src_rect)
  end
 

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