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.

Need help with hud

Oburi

Member

I need a little bit help with this script please...
Its an edit of a hud, I added some shortcuts at the bottom of the screen. But when I call a scene with it, the hp/sp/exp are over the new windows. Please help me, here is the code:

Code:
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('My HUD', 'Icedmetal57', "1.0", '8/1/2006')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('My HUD') == true


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
#=====================================
#Gradient Bars with customizable lengths, thicknesses, types and Colors
#By AcedentProne
#=====================================
 def draw_normal_barz(x, y, type, length, thick, e1, e2, c1 = Color.new(153,238,153,255), c2 = Color.new(0,0,0,255))
   if type == "horizontal"
     width = length
     height = thick
     self.contents.fill_rect(x-1, y - 1, width+2, height + 3, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width, height + 1, Color.new(0, 0, 0, 255))
     w = width * e1 / e2
     for i in 0..height
     r = c1.red + (c2.red - c1.red)   * (height -i)/height  + 0   * i/height
     g = c1.green + (c2.green - c1.green) * (height -i)/height  + 0 * i/height
     b = c1.blue + (c2.blue - c1.blue)  * (height -i)/height  + 0 * i/height
     a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height  + 255 * i/height
     self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
   end
 elsif type == "vertical"
   width = thick
   height = length
     self.contents.fill_rect(x-1, y - 1, width+3, height + 2, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width+1, height , Color.new(0, 0, 0, 255))
   h = height * e1 / e2
   for i in 0..width
     r = c1.red + (c2.red - c1.red)   * (width -i)/width  + 0   * i/width
     g = c1.green + (c2.green - c1.green) * (width -i)/width  + 0 * i/width
     b = c1.blue + (c2.blue - c1.blue)  * (width -i)/width  + 0 * i/width
     a = c1.alpha + (c2.alpha - c1.alpha)* (width -i)/width  + 255 * i/width
     self.contents.fill_rect(x+i, y, 1, h, Color.new(r, g, b, a))
   end
 end
end
def draw_actor_barz(actor,x, y, type, length, thick, e1, e2, c1 = Color.new(255,0,0,255), c2 = Color.new(0,0,0,255))
   if type == "horizontal"
     width = length
     height = thick
     self.contents.fill_rect(x-1, y - 1, width+2, height + 3, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width, height + 1, Color.new(0, 0, 0, 255))
     w = width * e1 / e2
     for i in 0..height
     r = c1.red + (c2.red - c1.red)   * (height -i)/height  + 0   * i/height
     g = c1.green + (c2.green - c1.green) * (height -i)/height  + 0 * i/height
     b = c1.blue + (c2.blue - c1.blue)  * (height -i)/height  + 0 * i/height
     a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height  + 255 * i/height
     self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
   end
 elsif type == "vertical"
   width = thick
   height = length
     self.contents.fill_rect(x-1, y - 1, width+3, height + 2, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width+1, height , Color.new(0, 0, 0, 255))
   h = height * e1 / e2
   for i in 0..width
     r = c1.red + (c2.red - c1.red)   * (width -i)/width  + 0   * i/width
     g = c1.green + (c2.green - c1.green) * (width -i)/width  + 0 * i/width
     b = c1.blue + (c2.blue - c1.blue)  * (width -i)/width  + 0 * i/width
     a = c1.alpha + (c2.alpha - c1.alpha)* (width -i)/width  + 255 * i/width
     self.contents.fill_rect(x+i, y, 1, h, Color.new(r, g, b, a))
   end
 end
end
  #--------------------------------------------------------------------------
  # * Draw EXP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 24, 32, "Exp")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 10, y, 84, 32, actor.exp_s, 2)
    self.contents.draw_text(x + 100, y, 12, 32, "/", 1)
    self.contents.draw_text(x + 112, y, 84, 32, actor.next_exp_s)
  end
end


#============================================
# Window_Map
# Originally by Destined, edited by Darklord and Icedmetal57
#============================================
class Window_HUD < Window_Base
  attr_accessor :Equip_button
  attr_accessor :Item_button
  attr_accessor :Status_button
  attr_accessor :Skill_button
  attr_accessor :PC_button
  attr_accessor :PM_button
  attr_accessor :Option_button
  attr_accessor :Beenden_button
  attr_accessor :Menubar
  def initialize
    super(0, 0, 200, 90) #360
    $game_actors[1].name = Network::Main.name
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 160
    #Oburi edit start
    @Equip_button = Window_Button.new(640-448,-56,56,56)
    @Item_button = Window_Button.new(640-392,-56,56,56)
    @Status_button = Window_Button.new(640-336,-56,56,56)
    @Skill_button = Window_Button.new(640-280,-56,56,56)
    @PC_button = Window_Button.new(640-224,-56,56,56)
    @PM_button = Window_Button.new(640-168,-56,56,56)
    @Option_button = Window_Button.new(640-112,-56,56,56)
    @Beenden_button = Window_Button.new(640-56,-56,56,56)
    @Equip_button.opacity = 160
    @Item_button.opacity = 160
    @Status_button.opacity = 160
    @Skill_button.opacity = 160
    @PC_button.opacity = 160
    @PM_button.opacity = 160
    @Option_button.opacity = 160
    @Beenden_button.opacity = 160  
    @Equip_button.contents = RPG::Cache.icon("equip")
    @Item_button.contents = RPG::Cache.icon("item")
    @Status_button.contents = RPG::Cache.icon("status")
    @Skill_button.contents = RPG::Cache.icon("skill")
    @PC_button.contents = RPG::Cache.icon("pc")
    @PM_button.contents = RPG::Cache.icon("pm")
    @Option_button.contents = RPG::Cache.icon("option")
    @Beenden_button.contents = RPG::Cache.icon("ende")
    # edit by Rid02
    @menu_status=0
    @Menubar = Window_Button.new(640-504,-56,504,71)
    @Menubar.opacity = 0
    # end edit by Rid02
    #Oburi edit end
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 16
    #self.contents.draw_text(36, 0, 640, 32, $game_actors[1].name.to_s)
    self.contents.font.color = normal_color
    chatc = RPG::Cache.icon("033-Item02")
    chat_rect = Rect.new(0, 0, chatc.width, chatc.height)
    self.contents.blt(120, 78, chatc, chat_rect) if $game_temp.chat_refresh
    #draw_normal_barz(6, 7, "horizontal", 150, 10, $game_actors[1].hp.to_i, $game_actors[1].maxhp.to_i, Color.new (225, 0, 0, 225))
    #draw_normal_barz(11, 22, "horizontal", 150, 10, $game_actors[1].sp.to_i, $game_actors[1].maxsp.to_i, Color.new (0,0,255,255))
    #draw_normal_barz(16, 37, "horizontal", 150, 10, $game_actors[1].exp_s.to_i, $game_actors[1].next_exp_s.to_i, Color.new (0, 255, 0, 225))
    #draw_actor_graphic($game_actors[1], 15, 63)
    #draw_actor_level($game_actors[1], 128, -17)
    draw_actor_hp($game_actors[1], 12, -3)
    draw_actor_sp($game_actors[1], 12, 12)
    draw_actor_exp($game_actors[1], 12, 27)
  end
  
  def show_menu
    if @menu_status<56
      @menu_status+=2 # scrolldown geschwindigkeit
      if @menu_status<42
        @Menubar.y=-56+@menu_status
      end
      @Equip_button.y=-56+@menu_status
      @Item_button.y=-56+@menu_status
      @Status_button.y=-56+@menu_status
      @Skill_button.y=-56+@menu_status
      @PC_button.y=-56+@menu_status
      @PM_button.y=-56+@menu_status
      @Option_button.y=-56+@menu_status
      @Beenden_button.y=-56+@menu_status
    end
  end
  
  def hide_menu
    if @menu_status>0
      @menu_status-=2 # scrollup geschwindigkeit
      if @menu_status>10
        @Menubar.y=-56+@menu_status
      end
      @Equip_button.y=-56+@menu_status
      @Item_button.y=-56+@menu_status
      @Status_button.y=-56+@menu_status
      @Skill_button.y=-56+@menu_status
      @PC_button.y=-56+@menu_status
      @PM_button.y=-56+@menu_status
      @Option_button.y=-56+@menu_status
      @Beenden_button.y=-56+@menu_status
    end
  end
  
  def dispose
    @Equip_button.dispose
    @Item_button.dispose
    @Status_button.dispose
    @Skill_button.dispose
    @PC_button.dispose
    @PM_button.dispose
    @Option_button.dispose
    @Beenden_button.dispose
    @Menubar.dispose
  end    
#  def update
#      refresh
#  end
end

#============================================
# Scene_Map
# Edits the scene Scene_Map
#============================================
class Scene_Map
  def initialize_hud
    @hud = Window_HUD.new
    @hud.opacity = 160#the opacity for the window. 0=completely transparent, 255=completely visible
    @player_hp = $game_actors[1].hp
    @player_sp = $game_actors[1].sp
    @player_exp = $game_actors[1].exp
    @player_gold = $game_party.gold
    @player_sprite = $game_actors[1].character_name
  end
  
  alias old_main main
  def main
    initialize_hud
    old_main
  end

  def dispose
    @hud.dispose
  end

  alias old_update update
  def update
    @hud.refresh if @player_hp != $game_actors[1].hp or @player_sp != $game_actors[1].sp or @player_exp != $game_actors[1].exp or @player_gold != $game_party.gold or @player_sprite != $game_actors[1].character_name or $game_temp.chat_refresh
    # Mausklick Tests
    if mouse_over?(@hud.Menubar)
      @hud.show_menu
    else
      @hud.hide_menu
    end
    if Input.triggerd?(Input::Mouse_Left)
      if mouse_over?(@hud.Equip_button)
        #$scene = Scene_Equip.new
      elsif mouse_over?(@hud.Item_button)
      #$scene = Scene_Item.new
      elsif mouse_over?(@hud.Status_button)
        #$scene = Scene_Status.new
      elsif mouse_over?(@hud.Skill_button)
        #$scene = Scene_Skill.new
      elsif mouse_over?(@hud.PC_button)
        $scene = Scene_PChat.new #warum geht es nicht??????
      elsif mouse_over?(@hud.PM_button)
        $scene = Scene_PM.new
      elsif mouse_over?(@hud.Option_button)
      elsif mouse_over?(@hud.Beenden_button)
           $scene = Scene_End.new
         end
    end
    old_update
  end
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
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