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.

Really simple HUD

Status
Not open for further replies.
I need a really simple HUD done, but I'm not sure how to do them myself.

Basically, all it is is this:
It takes up the top 32 pixels (The top row of tiles)
On the far left is the character's name
Next to that is his Remaining Hp/Max Hp
After that is his current money on the far right.

I don't even need any background or anything. Just text.

Thanks in advance.
 
Here you go! Insert above Main and change HUD_SHOW_ID to what switch ID you want to use to show the HUD.

Code:
HUD_SHOW_ID = 3
class Window_ActorHUD < Window_Base
  def initialize
    super(0, -16, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.visible = $game_switches[HUD_SHOW_ID]
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    gx = contents.text_size($data_system.words.gold).width
    self.contents.draw_text(604 - gx, 0, gx, 32, $data_system.words.gold)
    self.contents.font.color = normal_color
    self.contents.draw_text(604 - gx - 128, 0, 120, 32, $game_party.gold.to_s, 2)
    reset_variables
    return unless @actor
    draw_actor_name(@actor, 4, 0)
    draw_actor_hp(@actor, 128, 0)
  end
  def reset_variables
    @actor = $game_party.actors[0]
    @old_hp = @actor ? @actor.hp : 0
    @old_maxhp = @actor ? @actor.maxhp : 1
    @old_gold = $game_party.gold
  end
  def update
    super
    self.visible = $game_switches[HUD_SHOW_ID]
    refresh if @actor != $game_party.actors[0] ||
        $game_party.gold != @old_gold ||
        @actor && (@actor.hp != @old_hp || @actor.maxhp != @old_maxhp)
  end
end
class Scene_Map
  alias_method :hud_main, :main
  alias_method :hud_update, :update
  def main
    @hud = Window_ActorHUD.new
    hud_main
    @hud.dispose
  end
  def update
    hud_update
    @hud.update
  end
end
 
Status
Not open for further replies.

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