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] - @exp_list[current_level]
 - end
 - def gained_exp(current_exp, current_level)
 - return current_exp - @exp_list[current_level]
 - end
 - end
 - class Bitmap
 - def draw_gradient_rect(x, y, width, height, color1, color2)
 - for i in 0..width #can replace width with limit
 - mul = (width - i).to_f / width #can replace width with limit
 - color = Color.new(
 - mul * (color2.red - color1.red) + color1.red,
 - mul * (color2.green - color1.green) + color1.green,
 - mul * (color2.blue - color1.blue) + color1.blue
 - )
 - self.fill_rect(x + i, y, 1, height, color)
 - end
 - 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
 - when 4
 - return Color.new(255, 255, 255) # white
 - when 5
 - return Color.new(230, 230, 230) # offwhite
 - when 6
 - return Color.new(50, 0, 0) # barely red
 - when 7
 - return Color.new(0, 50, 0) # barely green
 - when 8
 - return Color.new(0, 0, 50) # barely blue
 - end
 - end
 - def draw_hp_bar(actor, x, y, w = 100)
 - hp = actor.hp
 - max_hp = actor.maxhp
 - border_color = bar_color(0)
 - health_color1 = bar_color(1)
 - health_color2 = bar_color(7)
 - hp_percentage = hp * 1.0 / max_hp
 - health_fill = w * hp_percentage
 - border = Rect.new(x - 1, y, w + 2, 10)
 - self.contents.fill_rect(border, border_color)
 - if hp > 0
 - health = self.contents.draw_gradient_rect(x, y + 1, health_fill, 8, health_color1, health_color2)
 - else
 - health = Rect.new(x, y, w, 8)
 - self.contents.fill_rect(health, border_color)
 - end
 - end
 - def draw_xp_bar(actor, x, y, w = 100)
 - exp = actor.exp
 - level = actor.level
 - gained_exp = actor.gained_exp(exp, level)
 - needed_exp = actor.needed_exp(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