Im trying to make a hud kinda thing that displays your party's HP and MP and names and such in the 4 corners of the screen. The code works ok but only when I have 4 party members. I think it might be an if statement but I dont know how to code it :/ help please :]
Code:
class Window_PlayerHPMPHud < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width-32, height-32)
self.opacity = 0
self.contents.clear
refresh
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
y = 10
x = 10
actor = $game_party.actors[0]
draw_actor_graphic(actor, x + 10, y + 40)
draw_actor_name(actor, x + 30, y)
draw_actor_hp(actor, x + 110, y - 10)
draw_actor_sp(actor, x + 110, y + 10)
actor = $game_party.actors[1]
draw_actor_graphic(actor, x + 350, y + 40)
draw_actor_name(actor, x + 380, y)
draw_actor_hp(actor, x + 460, y - 10)
draw_actor_sp(actor, x + 460, y + 10)
actor = $game_party.actors[2]
draw_actor_graphic(actor, x + 10, y + 430)
draw_actor_name(actor, x + 30, y + 390)
draw_actor_hp(actor, x + 110, y + 380)
draw_actor_sp(actor, x + 110, y + 400)
actor = $game_party.actors[3]
draw_actor_graphic(actor, x + 350, y + 430)
draw_actor_name(actor, x + 380, y + 390)
draw_actor_hp(actor, x + 460, y + 380)
draw_actor_sp(actor, x + 460, y + 400)
end
end
class Scene_Map
alias playerhpmphud_main main
alias playerhpmphud_update update
def main
@playerhpmphud = Window_PlayerHPMPHud.new
playerhpmphud_main
@playerhpmphud.dispose
end
def update
@playerhpmphud.update
playerhpmphud_update
end
end