Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement