Unique HUD request (hp/mp bar that streches)

Hello,
I would like to have a simple HUD, with just 3 bars. HP Bar, MP Bar and XP Bar. As for HP and MP bar, the lenght of this bars would be based on how much max hp the main actor has (first in party). Each time i incerease max HP or max MP the bar would be longer a little bit. Let's say one pixel per 10 max HP/MP. And also i would like to display above each bar aa number: current hp/max hp. Also at the beginning of the bars an icon. Ofcourse i would not like it to be picture based, unles the picture will stretch too. As for XP bar, i would like it to be at the bottom of the screen, and above it a % of how it is filled, in a for example: 56.7% format.
You can make it picture based, and still adjust... so this is for an on-map HUD right?
You can make it picture based, and still adjust... so this is for an on-map HUD right?
But i think i have to make tons of pictures for every max HP so it will be longer the more max hp you have.

Yes, this is for on-map HUD, i want to replace the HUD from Blasphemia ABS (as soon as i fix something i broke in it, wich is using items/skills from hotkeys broke for some reason..)
as I said you can use pictures and it will still adjust... by adjust I mean it will still be longer/shorter depending on your HP or anything else... I have actually made one, but I forgot it on my flash drive... I'll try to remake it or something...
If you think about same thing then that's cool. But i think that you are talking about current hp. In every hud current hp will stretch that's right, but what i want is the bar strech with every gain of MaxHP. Something like this:
max HP 100
 [####]
max HP 100, current 75
 [###0]

max HP increased to 125
 [#####]

[ and ] represents the lenght of the bar. See when max hp is increased there is 5 # insted of 4? (0 in the bar means the black bit of the bar.
I think Shana got it.

zoom_x for max status, and src_rect.width for current status.

zoom_x will stretch the picture horizontally.

src_rect.width will display the picture based on the given measurement.

For example:

You have picture for hp. Let's name it 'hp_sprite'

@testing_sprite = Sprite.new@testing_sprite.bitmap = Cache.picture('hp_sprite')The limit of max hp in your game is 50k and that takes the whole screen from left to right, so your pic, would have 544 (Graphics.width) width, your character max hp is 500, which is .01 in comparison with the max available hp, so the picture zoom_x would be:

@testing_sprite.zoom_x = your_character_max_hp / limit_max_hp.to_f By above logic, 544 would be displayed as 5 (very very short) instead of 5.44 due to pixel rounding.

Then for whatever reason, your character hp is decreased by 200. You would like to only display the 300, the picture src_rect.width would be:

@testing_sprite.src_rect.width = @testing_sprite.bitmap.width * your_character_current_hp / your_character_max_hp.to_f By above logic, 5 would be displayed as 3 (extremely short..., I should have used a better comparison, but oh well, you got the idea).

If you want to add text, don't draw it on your picture, you could just display the information as letter any place you desired.
I'm the one who's doing it, and I'm telling you that IT CAN BE DONE, so don't tell me that it cannot be... Do you even know why current hp bars scale with current hp? because they made it to scale, and doing the same thing for max hp isn't a hard thing to do, really...

try this use either pictures or just the default color-based gauges... I haven't tested it though so I'm not sure if it works fine...

Spoiler
module ADIK module MAP_HUD #HUD modes #"constant" => maximum length of bars/gauges is constant #"scaling" => maximum length of bars/gauges scale depending on maximum MODE = "constant" #Maximum width of hp gauges : constant mode GAUGE_WIDTH_HP = 544/4 #Height of hp gauges GAUGE_HEIGHT_HP = 416/10 #Maximum width of mp gauges : constant mode GAUGE_WIDTH_MP = 544/4 #Height of mp gauges GAUGE_HEIGHT_MP = 416/10 #HP per pixel : scaling mode HP_PER_PIXEL = 10 #MP per pixel : scaling mode MP_PER_PIXEL = 10 #Use gauge images? GAUGE_IMAGES = false #If true: #HP Gauge background GAUGE_BG_HP = "" #MP Gauge background GAUGE_BG_MP = "" #HP Gauge image GAUGE_HP = "" #MP Gauge image GAUGE_MP = "" #else #Color.new(R,G,B,A) #Set A to 0 if you want invisible #HP Gauge background color GAUGE_BGC_HP = Color.new(50,50,50,150) #MP Gauge background color GAUGE_BGC_MP = Color.new(50,50,50,150) #HP Gauge color GAUGE_C_HP = Color.new(0,255,0,200) #MP Gauge color GAUGE_C_MP = Color.new(0,0,255,200) #Use gradient color? GAUGE_GRADIENT = true #HP Gauge color 2 GAUGE_C_HP_2 = Color.new(200,255,0,200) #MP Gauge color 2 GAUGE_C_MP_2 = Color.new(200,0,255,200) #end #X position of hp gauge X_HP = 50 #Y position of hp gauge Y_HP = 50 #X position of mp gauge X_MP = 100 #Y position of mp gauge Y_MP = 100 #Z of gauges GAUGES_Z = 300 #Actor ID ACTOR = 1 attr_accessor :use_hud attr_accessor :sprite_bg attr_accessor :sprite_b attr_accessor :viewport attr_accessor :hp_bg_bit attr_accessor :mp_bg_bit attr_accessor :hp_b_bit attr_accessor :mp_b_bit attr_accessor :actor attr_accessor :hp attr_accessor :mp attr_accessor :maxhp attr_accessor :maxmp def self.init @use_hud = false @viewport = Viewport.new @sprite_bg = Sprite_Base.new(@viewport) @sprite_bg.z = GAUGES_Z - 1 @sprite_bg.bitmap = Bitmap.new(544,416) @sprite_b = Sprite_Base.new(@viewport) @sprite_b.z = GAUGES_Z @sprite_b.bitmap = Bitmap.new(544,416) if GUAGE_IMAGES @hp_bg_bit = Cache.pictures(GAUGE_BG_HP) @mp_bg_bit = Cache.pictures(GAUGE_BG_MP) @hp_b_bit = Cache.pictures(GAUGE_HP) @mp_b_bit = Cache.pictures(GAUGE_MP) end @actor = $game_actors[ACTOR] @hp = [] @mp = [] @maxhp = [] @maxmp = [] end def self.toggle @use_hud = not @use_hud if @use_hud self.update(true) else @sprite_b.bitmap.clear @sprite_bg.bitmap.clear end end def self.change_actor(id) @actor = $game_actors[id] self.update end def self.update(forced=false) unless forced return if not @use_hud return if not SceneManager.scene_is?(Scene_Map) #return if scene_changing? return if not @actor return if @actor.hp == @hp[actor.id] and @actor.mp == @mp[actor.id] and @actor.mhp == @maxhp[actor.id] and @actor.mmp == @maxmp[actor.id] end @hp[actor.id] = @actor.hp @mp[actor.id] = @actor.mp @maxhp[actor.id] = @actor.mhp @maxmp[actor.id] = @actor.mmp @sprite_b.bitmap.clear @sprite_bg.bitmap.clear if MODE == "constant" rect_hp = Rect.new(X_HP,Y_HP,GAUGE_WIDTH_HP,GAUGE_HEIGHT_HP) rect_mp = Rect.new(X_MP,Y_MP,GAUGE_WIDTH_MP,GAUGE_HEIGHT_MP) else rect_hp = Rect.new(X_HP,Y_HP,@actor.mhp/HP_PER_PIXEL,GAUGE_HEIGHT_HP) rect_mp = Rect.new(X_MP,Y_MP,@actor.mmp/MP_PER_PIXEL,GAUGE_HEIGHT_MP) end if GAUGE_IMAGES rect = Rect.new(0,0,@hp_bg_bit.width,@hp_bg_bit.height) @sprite_bg.bitmap.stretch_blt(rect_hp,@hp_bg_bit,rect) rect = Rect.new(0,0,@mp_bg_bit.width,@mp_bg_bit.height) @sprite_bg.bitmap.stretch_blt(rect_mp,@mp_bg_bit,rect) rect = Rect.new(0,0,@hp_b_bit.width,@hp_b_bit.height) rect_hp.width *= @actor.hp_rate @sprite_b.bitmap.stretch_blt(rect_hp,@hp_bg_bit,rect) rect_mp.width *= @actor.mp_rate rect = Rect.new(0,0,@mp_b_bit.width,@mp_b_bit.height) @sprite_b.bitmap.stretch_blt(rect_mp,@mp_bg_bit,rect) else @sprite_bg.bitmap.fill_rect(rect_hp,GAUGE_BGC_HP) @sprite_bg.bitmap.fill_rect(rect_mp,GAUGE_BGC_MP) rect_hp.width *= @actor.hp_rate rect_mp.width *= @actor.mp_rate if GAUGE_GRADIENT @sprite_bg.bitmap.gradient_fill_rect(rect_hp,GAUGE_C_HP,GAUGE_C_HP_2) @sprite_bg.bitmap.gradient_fill_rect(rect_mp,GAUGE_C_MP,GAUGE_C_MP_2) else @sprite_bg.bitmap.fill_rect(rect_hp,GAUGE_C_HP) @sprite_bg.bitmap.fill_rect(rect_mp,GAUGE_C_MP) end end end endendclass Scene_Map alias update_adik_map_hud update def update update_adik_map_hud ADIK::MAP_HUD.update endend
just set-up the variables, and then do a script call: ADIK::MAP_HUD.toggle, do it again to turn it off...

and again, this script has not been tested so it might have problems...
I've got an error:
 
p9sn.png
yes you would... XD...


I'm uploading the fixed, full version on the scripts section... I'll tell you once it's approved... it can show HP/MP/TP/EXP, any of those, you can even show them all...


EDIT: It might take a bit for it to get approved so just get it directly from here: http://lescripts.wordpress.com/rgss3/map-hud/

Original thread: https://forums.rpgmakerweb.com/threads/unique-hud-request-hp-mp-bar-that-streches.22436/