
Group: Banned
Posts: 0
Type: None
RM Skill: Undisclosed

|
Hi,
This script is a plug and play script, which displays a HUD that slides in to the top left of your gamescreen, it's a pretty basic layout that displays the actors name, HP, SP and EXP;
CODE #============================================================================== # ** JBrist Sliding HUD - By JBrist #------------------------------------------------------------------------------ # 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 corresponds 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, 210, 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- The instructions are included in the script, I'll paste them here though;
CODE 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 corresponds to Z (Usually D), if you don't want it to be this, edit this line further down:
@hudwindow.visible = Input.press?(Input::Z)
Also, if you'd like to change any of the words (HP/SP/Exp.) as you can see on the example, I changed it to MP (I prefer using MP)
To change HP; Change 'HP' to anything you'd like (Line 95)
CODE specialized_draw_hud(x, y, 'HP', hp_str) To change MP; Change 'MP' to anything you'd like (Line 108)
CODE specialized_draw_hud(x, y, 'MP', sp_str) To change Exp; Change 'Exp.' to anything you'd like (Line 121)
CODE specialized_draw_hud(x, y, 'Exp.', exp_str
Thankyou, and please comment on anything, ~JBrist.
|