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.

JBrist Sliding HUD

Jason

Awesome Bro

JBrist Sliding HUD


Hi everyone,

So I haven't made any scripts for a while, well, not any good ones, although I will admit I thought my Info. Cards script was pretty darn useful (Trainer Cards FTW !),

Not sure if you can remember, a while ago I made a HUD which looked pretty good visually, but because I never got the refresh rate done or anything, it lagged like a bitch, lol.

So now I'm releasing a NEW HUD;

Basically, when you press a button (Which can be assigned via the script) a box displaying your characters name, HP, SP and EXP will slide in from the left, and stay in the top left corner, until you release the button, simple yet effective;

Script ---
Code:
#==============================================================================

# ** JBrist Slide HUD - By JBrist of rmxp.org

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

# Instructions of use :

#   This is a simple plug and play script, just insert it into a new

#   script above Main, and away you go. To show the HUD while ingame

#   press the button which corrosponds to Z (Usually D), if you don't 

#   want it to be this, edit this line further down:

#

#       @hudwindow.visible = Input.press?(Input::Z)

#

#                           JBrist

#=============================================================================

 

#==============================================================================

# ** Window_Base

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

#  This class is for all in-game windows.

#==============================================================================

 

class Window_Base < Window

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

  # * Get the clear color.

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

  def clear_color

    return Color.new(0, 0, 0, 0)

  end

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

  # * Clear a certain number of pixel rows on the bitmap.

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

  def clear_rows(y, height)

    rect = Rect.new(0, y, width - 32, height)

    self.contents.fill_rect(rect, clear_color)

  end

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

  # * Specialized hud drawing stats.

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

  def specialized_draw_hud(x, y, left, right, height = 24)

    self.contents.font.color = system_color

    self.contents.draw_text(x, y, 60, height, left)

    self.contents.font.color = normal_color

    self.contents.draw_text(x, y, width - 32, height, right, 2)

  end

end

 

#==============================================================================

# ** Jbrist_HUD

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

#  This class performs hud processing when on Scene_Map.

#==============================================================================

 

class Jbrist_HUD <  Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 260, 130)#210, 130

    self.contents = Bitmap.new(width - 32, height - 32)

    self.back_opacity = 255

    # Not visible by default.

    self.visible = false

    

    self.contents.fill_rect(0, 24, width - 32, 2, system_color)

    # Save the actor that will be doing the drawing for.

    @actor = $game_party.actors[0]

    refresh

  end

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

  # * Refresh

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

  def refresh

    # Drawing values.

    x, y, height_inc = 0, 0, 24

    

    # Draw the Name of the Party Leader.

    if @actor_name != @actor.name

      # Save the new value

      @actor_name = @actor.name

      # Create a rectangle to clear the portion we will draw to.

      clear_rows(y, height_inc)

      # Draw the actors name.

      specialized_draw_hud(x, y, "Name", @actor.name)

    end

    

    y += height_inc + 2

    

    # Draw the Hitpoints of the Party Leader.

    if @actor_hp != @actor.hp

      # Save the new value

      @actor_hp = @actor.hp

      # Create a rectangle to clear the portion we will draw to.

      clear_rows(y, height_inc)

      # Draw the health points.

      hp_str = @actor.hp.to_s + ' / ' + @actor.maxhp.to_s

      specialized_draw_hud(x, y, 'HP', hp_str)

    end

    

    y += height_inc

    

    # Draw the Skill Points of the Party Leader.

    if @actor_sp != @actor.sp

      # Save the new value

      @actor_sp = @actor.sp

      # Create a rectangle to clear the portion we will draw to.

      clear_rows(y, height_inc)

      # Draw the skill points.

      sp_str = @actor.sp.to_s + ' / ' + @actor.maxsp.to_s

      specialized_draw_hud(x, y, 'MP', sp_str)

    end

    

    y += height_inc

    

    # Draw the Experience of the Party Leader.

    if @actor_exp != @actor.exp

      # Save the new value

      @actor_exp = @actor.exp

      # Create a rectangle to clear the portion we will draw to.

      clear_rows(y, height_inc)

      # Draw the experience.

      exp_str =  @actor.exp.to_s + ' / ' + @actor.next_exp_s

      specialized_draw_hud(x, y, 'Exp.', exp_str)

    end

  end

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

  # * Frame Update

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

  def update

    @actor = $game_party.actors[0]

    refresh

  end

end

 

#==============================================================================

# ** Scene_Map

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

#  This class performs map screen processing.

#==============================================================================

 

class Scene_Map

  alias_method :jbri_hudwindow_main, :main

  alias_method :jbri_hudwindow_update, :update

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

  # * Main Processing

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

  def main

    @hudwindow = Jbrist_HUD.new

    jbri_hudwindow_main

    @hudwindow.dispose

  end

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

  # * Frame Update

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

  def update

    @hudwindow.update

    @hudwindow.visible = Input.press?(Input::Z)

    if @hudwindow.visible

      if @hudwindow.x < 0

        @hudwindow.x += @hudwindow.width / 10

        @hudwindow.opacity += @hudwindow.width / 10

      end

    else

      @hudwindow.x = @hudwindow.width * -1

      @hudwindow.opacity = 255 - @hudwindow.width

    end

    jbri_hudwindow_update

  end

end

 

 


Instructions ---

It's basically a Plug n' Play script, so you shouldn't find it too difficult, if you'd like to change which button opens the HUD, it's all in the script for you, but I'll paste the line anyways;

@hudwindow.visible = Input.press?(Input::Z)

And thats it.

Compatability ---

I have NO idea about the compatability, I'm guessing it'll work with everything cause it doesn't edit any classes or anything like that.

Credit ---

Yeah, if you use, just credit me as JBrist, cheers.

And thats the script, feedback ?
 
NICE MAP OMG!

Hehe, good script mate. I never managed to make a HUD... Maybe, cus it seems you need to press a button to open it, let it be open all the time? But if you do that, be sure to make it smaller.
 

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