Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Game_Actor < Game_Battler
- def needed_exp(current_level)
- return @exp_list[current_level + 1]
- end
- def gained_exp(current_level, current_exp)
- return (current_exp - @exp_list[current_level])
- end
- def lvl
- return @level
- end
- end
- class Window_Base < Window
- def bar_color(n)
- case n
- when 0
- return Color.new(0, 0, 0) # black
- when 1
- return Color.new(0, 255, 0) # green
- when 2
- return Color.new(0, 0, 255) # blue
- when 3
- return Color.new(255, 0, 0) # red
- end
- end
- def draw_hp_bar(actor, x, y, w = 100)
- hp = actor.hp
- max_hp = actor.maxhp
- border_color = bar_color(0)
- health_color = bar_color(1)
- hp_percentage = hp * 1.0 / max_hp
- health_fill = w * hp_percentage
- border = Rect.new(x - 1, y, w + 2, 10)
- health = Rect.new(x, y, health_fill, 8)
- self.contents.fill_rect(border, border_color)
- self.contents.fill_rect(health, health_color)
- end
- def draw_xp_bar(actor, x, y, w = 100)
- exp = actor.exp
- gained_exp = actor.gained_exp(actor.level, exp)
- needed_exp = actor.needed_exp(actor.level)
- exp_percentage = (gained_exp * 1.0 / needed_exp) * w
- background_color = bar_color(0)
- first_bar_color = bar_color(4)
- second_bar_color = bar_color(5)
- background_bar = Rect.new(x - 1, y, w + 2, 10)
- first_bar = Rect.new(x, y + 1, exp_percentage, 8)
- second_bar = Rect.new(x, y + 3, exp_percentage, 4)
- self.contents.fill_rect(background_bar, background_color)
- self.contents.fill_rect(first_bar, first_bar_color)
- self.contents.fill_rect(second_bar, second_bar_color)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement