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.

[Resolved]help with modified script.

Status
Not open for further replies.
I've got the Kingdom Hearts HUD Script

Which I have modified slightly for my rpg, but two things i can't seem to work out.

I would like the hud to disappear completely when you press escape to get back to the menu (and then return when you go back to main game), I would also like the players level to appear in the yellow semi circle at the bottom. (screenshot below)

Would somebody be able to help?. It would be greatly appreciated.

heres the script i'm using

Code:
#==============================================================================
# â–  Kingdom Hearts HUD
#------------------------------------------------------------------------------
# by Skive
# skivedaft@yahoo.com
#
# --
#
# released on 5th March 2006
#==============================================================================

#==============================================================================
# â–  Sprite_HP
#------------------------------------------------------------------------------
#  the HUD's hp bar
#==============================================================================

class Sprite_HP < Sprite
#--------------------------------------------------------------------------
# ● instances
#--------------------------------------------------------------------------
attr_writer :actor
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(actor = nil)
 
super(nil)
self.z = 202
self.bitmap = Bitmap.new(60, 26)
@actor = actor
if !@actor.nil?
@hp = @actor.hp
@maxhp = @actor.maxhp
end
refresh
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.bitmap.clear
return if @actor.nil?
@hp = @actor.hp
@maxhp = @actor.maxhp
draw_bar(20, 6)
self.angle = 270
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
if @actor.nil?
self.bitmap.clear
return
end
if @hp != @actor.hp or @maxhp != @actor.maxhp
refresh
end
end
#--------------------------------------------------------------------------
# ● draw_bar
#--------------------------------------------------------------------------
def draw_bar(radius, width)
    
max = (@actor.hp * 360) / @actor.maxhp
for j in 1..width
for i in 0..max
bx = Math.cos( (i * Math::PI) / 360) * (radius + j)
by = Math.sin( (i * Math::PI) / 360) * (radius + j)
case j
when 1
color = Color.new(150, 0, 0)
when 2
color = Color.new(170, 0, 0)
when 3
color = Color.new(190, 0, 0)
when 4
color = Color.new(210, 0, 0)
when 5
color = Color.new(230, 0, 0)
when 6
color = Color.new(255, 0, 0)
end
self.bitmap.set_pixel(30 + bx, by, color)
end
end
end
end

#==============================================================================
# â–  Sprite_SP
#------------------------------------------------------------------------------
#  the HUD's sp bar
#==============================================================================

class Sprite_SP < Sprite
#--------------------------------------------------------------------------
# ● instances
#--------------------------------------------------------------------------
attr_writer :actor
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(actor = nil)
super(nil)
self.z = 202
self.bitmap = Bitmap.new(60, 26)
@actor = actor
if !@actor.nil?
@sp = @actor.sp
@maxsp = @actor.maxsp
end
refresh
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.bitmap.clear
return if @actor.nil?
@sp = @actor.sp
@maxsp = @actor.maxsp
draw_bar(20, 6) #20,6
self.angle = 90
self.mirror = true
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
if @actor.nil?
self.bitmap.clear
return
end
if @sp != @actor.sp or @maxsp != @actor.maxsp
refresh
end
end
#--------------------------------------------------------------------------
# ● draw_bar
#--------------------------------------------------------------------------
def draw_bar(radius, width)
max = (@actor.sp * 360) / @actor.maxsp
for j in 1..width
for i in 0..max
bx = Math.cos( (i * Math::PI) / 360) * (radius + j)
by = Math.sin( (i * Math::PI) / 360) * (radius + j)
case j
when 1
color = Color.new(29, 82, 112)
when 2
color = Color.new(29, 86, 120)
when 3
color = Color.new(28, 90, 131)
when 4
color = Color.new(27, 96, 144)
when 5
color = Color.new(26, 102, 156)
when 6
color = Color.new(26, 106, 167)
end
self.bitmap.set_pixel(30 + bx, by, color)
end
end
end
end

#==============================================================================
# â–  Sprite_HUD
#------------------------------------------------------------------------------
#  draws the HUD on the map
#==============================================================================

class Sprite_HUD < Sprite
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(corner = 4)
super(nil)
self.z = 200
for actor in $game_party.actors
next if actor.dead?
@actor = actor
@actor_index = $game_party.actors.index(@actor)
break
end
@hp_sprite = Sprite_HP.new(@actor)
@sp_sprite = Sprite_SP.new(@actor)
self.bitmap = Bitmap.new(375, 220)
case corner
when 1
x = 16
y = 16
when 2
x = 640 - 52 - 16
y = 16
when 3
x = 320
y = 20
when 4
x = 170
y = 415

xh = 295
yh= 415
end
self.x = x
self.y = y
@hp_sprite.x = xh + 19   # + 27
@hp_sprite.y = yh + 9    #3
@sp_sprite.x = xh + 32 - 1    #27-1
@sp_sprite.y = yh + 68  #3-1+ 60
refresh
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.bitmap.clear
return if @actor.nil?

bitmap = RPG::Cache.picture("background")
self.bitmap.blt(0, 10, bitmap, Rect.new(0, 0, 375, 220))


end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
@hp_sprite.update
@sp_sprite.update
if @actor != $game_party.actors[@actor_index]
@actor = $game_party.actors[@actor_index]
@hp_sprite.actor = @actor
@sp_sprite.actor = @actor
@hp_sprite.refresh
@sp_sprite.refresh
refresh
end
end
end

#==============================================================================
# â–  Scene_Map
#------------------------------------------------------------------------------
#  draws the hud on the map screen
# @khhud_corner is the corner you want the hud to be displayed in.
# 1 is upper left, 2 is upper right, 3 is bottom left and 4 is bottom right
#==============================================================================

class Scene_Map
alias main_khhud main
alias update_khhud update
alias transfer_khhud transfer_player
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize
@khhud_corner = 4 # 1 or 2 or 3 or 4
end
#--------------------------------------------------------------------------
# ● main
#--------------------------------------------------------------------------
def main
@hud = Sprite_HUD.new(@khhud_corner)
main_khhud
@hud.dispose
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
@hud.update
update_khhud
end
end

heres the screenshot.

http://img6.picsplace.to/img6/25/EternitysEnd_HUD.JPG[/img]
 
That's pretty easy. ^_^
Just paste this in a new script above main and below the HUD.
Code:
class Sprite_HUD < Sprite
  alias raz_fix_sprite_refresh refresh
  def refresh
    raz_fix_sprite_refresh
    self.bitmap.font.bold = true
    self.bitmap.font.size = 18
    self.bitmap.font.color = Color.new(0, 0, 0)
    self.bitmap.draw_text(147, 38, 150, 32, $game_party.actors[0].level.to_s)
    self.bitmap.draw_text(145, 36, 150, 32, $game_party.actors[0].level.to_s)
    self.bitmap.draw_text(147, 36, 150, 32, $game_party.actors[0].level.to_s)
    self.bitmap.draw_text(145, 38, 150, 32, $game_party.actors[0].level.to_s)
    self.bitmap.font.color = Color.new(255, 255, 255)
    self.bitmap.draw_text(146, 37, 150, 32, $game_party.actors[0].level.to_s)
  end
  def dispose
    super
    @hp_sprite.dispose
    @sp_sprite.dispose
  end
end
 
This topic has been resolved. If Hairdude or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
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