07-14-2006, 01:00 PM (This post was last modified: 05-12-2017, 03:44 AM by DerVVulfman.)
Hud Menu
Raziel
Version: 1.2
Jul 14 2006
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Introduction
A short script I did when I was bored. tongue.gif
Features
Turn the Hud on and off by using a switch.
Includes HP, SP, Exp and gradient bars.
The feature to center the HUD.
Script
Place this above main
Code:
class Scene_Map
SWITCH_ID = 1
$center_hud = false
alias raz_hud_main main
alias raz_hud_update update
def main
@size = $game_party.actors.size
raz_hud_main
@hud_window.dispose
for i in 0...$game_party.actors.size
@hud_dummy[i].dispose
end
end
def update
if @size != $game_party.actors.size
@hud_window.refresh
show_window
end
if @hud != true
main_window
end
turn_hud_on_off
@hud_window.update
raz_hud_update
end
def show_window
@size = $game_party.actors.size
for i in 0..3
@hud_dummy[i].visible = ($game_party.actors[i] != nil)
end
end
def main_window
@opacity = 200
@hud_dummy = []
for i in 0...4
y = $game_party.actors.size - 1
x = 240 - (y * 80)
if $center_hud == true
@hud_dummy[i] = Window_Base.new(160 * i + x, 372,160, 108)
else
@hud_dummy[i] = Window_Base.new(160 * i, 372,160, 108)
end
@hud_dummy[i].opacity = @opacity
@hud_dummy[i].visible = false
end
@hud_window = Window_HUD.new
for i in 0...$game_party.actors.size
@hud_dummy[i].visible = $game_party.actors[i] != nil
end
@hud = true
end
def turn_hud_on_off
if $game_switches[SWITCH_ID] == false
@hud_window.visible = false
for i in 0...$game_party.actors.size
@hud_dummy[i].visible = false
end
end
if $game_switches[SWITCH_ID] == true
@hud_window.visible = true
for i in 0...$game_party.actors.size
@hud_dummy[i].visible = true
end
end
end
end
class Window_HUD < Window_Base
def initialize
super(0, 0, 800, 600)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
toto("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
end
refresh
end
def update
super
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if (toto("@old_hp#{i+1}") != actor.hp or toto("@old_sp#{i+1}") != actor.sp or
toto("@old_exp#{i+1}") != actor.now_exp)
refresh
toto("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
end
end
end
end
class Window_Base < Window
def draw_slant_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
end
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
for i in 1..( (min / max.to_f) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end
class Game_Actor
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
Instructions
Turn the HUD on/off by using a switch. Turn the HUD off, turn the switch to off, to turn the HUD on, change the switch to on. The default switch is 1. To change it, just change the 1 in SWITCH_ID = 1 to the number of the switch you want to use.
To center the HUD just turn $center_hud to true. Turn it off when you don't want to center the HUD.
FAQ
How to exchange the window with a picture
Just exchange this part in the script
Code:
if $center_hud == true
@hud_dummy[i] = Window_Base.new(160 * i + x, 372,160, 108)
else
@hud_dummy[i] = Window_Base.new(160 * i, 372,160, 108)
end
With this:
Code:
@hud_dummy[i] = Sprite.new
@hud_dummy[i].bitmap = RPG::Cache.picture("hud_background")
@hud_dummy[i].y = 372
if $center_hud == true
@hud_dummy[i].x = 160 * i + x
else
@hud_dummy[i].x = 160 * i
end
Now put a picture in the Pictures folder with the size 160 x 108 and name it hud_background.
Credits and Thanks
Thanks and credits to SephirothSpawn for the gradient bars.
Thanks to Trickster for editing the script to make it shorter/easier. smile.gif