I tried to put it in, but had a bit of trouble understanding the code. Dealing with graphics is my weak point in coding still.
alright, I've been working with this for awhile, and I still can't get it to work right. The HP doesn't display properly, it just shows one image(though it is showing the correct image), no matter how much health the actor has. Here's a screenie:
class Scene_Menu
def initialize
# set the background #
@spriteset = Spriteset_Map.new
# create the windows #
@actor_list = []
$game_party.actors.each_index{|actor|
@actor_list.push Window_Party_Actor.new($game_party.actors[actor].id,actor)}
#@obj_description = Window_Obj_Description.new
#@window_menu_commands = Window_Menu_Comands.new
end
def main
# enter the scene's loop #
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
# dispose of the windows #
Graphics.freeze
@actor_list.each{|actorWindow|actorWindow.dispose}
#@class_list.dispose
#@class_description.dispose
@spriteset.dispose
end
def update
@actor_list.each{|actorWindow|actorWindow.update}
#@obj_description.update
#@window_menu_commands.update
@spriteset.update
end
end
class Window_Base
def draw_tiled_hp(actor,mode,x,y,w,h)
rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)
b1 = RPG::Cache.picture("HUD/" + BlizzCFG::Z_HP_FILE + mode)
b2 = RPG::Cache.picture("HUD/" + BlizzCFG::Z_HP_FILE_EMPTY + mode)
tiles = actor.maxhp / BlizzCFG::Z_HP_PER_TILE
rows = (tiles.to_f / BlizzCFG::Z_HP_TILE_COLUMNS).ceil
w, h = b1.width, b1.height
self.contents.fill_rect(x, y, w * BlizzCFG::Z_HP_TILE_COLUMNS,
h * rows, Color.new(0, 0, 0, 0))
full_tiles = (rate * tiles).to_i
semi_full = ((rate * tiles != full_tiles) ? 1 : 0)
(0...full_tiles).each {|i|
draw_x = x + (i % BlizzCFG::Z_HP_TILE_COLUMNS) * w
draw_y = y + (i / BlizzCFG::Z_HP_TILE_COLUMNS) * h
self.contents.blt(x, y, b1, Rect.new(0, 0, w, h))}
if semi_full > 0
draw_x = x + (full_tiles % BlizzCFG::Z_HP_TILE_COLUMNS) * w
draw_y = y + (full_tiles / BlizzCFG::Z_HP_TILE_COLUMNS) * h
if BlizzCFG::Z_HP_FILL_UP
h2 = ((1 - rate * tiles + full_tiles) * h).to_i
self.contents.blt(draw_x, draw_y, b2, Rect.new(0, 0, w, h2))
self.contents.blt(draw_x, draw_y + h2, b1, Rect.new(0, h2, w, h - h2))
else
w2 = ((rate * tiles - full_tiles) * w).to_i
self.contents.blt(x, y, b1, Rect.new(0, 0, w2, h))
self.contents.blt(x + w2, y, b2, Rect.new(w2, 0, w - w2, h))
end
end
((full_tiles + semi_full)...tiles).each {|i|
draw_x = x + (i % BlizzCFG::Z_HP_TILE_COLUMNS) * w
draw_y = y + (i / BlizzCFG::Z_HP_TILE_COLUMNS) * h
self.contents.blt(draw_x, draw_y, b2, Rect.new(0, 0, w, h))}
end
end
class Window_Party_Actor < Window_Base
def initialize(actorID,num)
@actorID = actorID
super(88, (64 + (num * 88)), 240, 88)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 22
refresh
end
def refresh
self.contents.clear
draw_actor_name($game_actors[@actorID], 0, 0)
draw_tiled_hp($game_actors[@actorID],'_thumb',0,28,200,64)
end
end
if anyone could help me figure this out, that'd be great. (btw, if you're wondering why I'm using self.contents for the draw_tiled_hp method rather than self.bitmap like in the ZHud, it's because windows use self.contents for methods such as fill_rect.