View difference between Paste ID: iq7QcYMm and bqW8BL2E
SHOW: | | - or go back to the newest paste.
1
class Game_Actor < Game_Battler
2
	
3-
  def needed_exp(current_level)
3+
	def needed_exp(current_level)
4-
    return @exp_list[current_level + 1]
4+
    return @exp_list[current_level + 1] - @exp_list[current_level]
5
  end
6
  
7-
  def gained_exp(current_level, current_exp)
7+
  def gained_exp(current_exp, current_level)
8-
    return (current_exp - @exp_list[current_level])
8+
    return current_exp - @exp_list[current_level]
9
  end
10
	
11-
  def lvl
11+
12-
    return @level
12+
13
class Bitmap
14
	
15
	def draw_gradient_rect(x, y, width, height, color1, color2)
16
		for i in 0..width #can replace width with limit
17
			mul = (width - i).to_f / width #can replace width with limit
18
			color = Color.new(
19
				mul * (color2.red - color1.red) + color1.red,
20
				mul * (color2.green - color1.green) + color1.green,
21
				mul * (color2.blue - color1.blue) + color1.blue
22
			)
23
			self.fill_rect(x + i, y, 1, height, color)
24-
		when 0
24+
25-
			return Color.new(0, 0, 0)  # black
25+
26-
		when 1
26+
27-
			return Color.new(0, 255, 0)  # green
27+
28-
		when 2
28+
29-
			return Color.new(0, 0, 255)  # blue
29+
30-
		when 3
30+
31-
			return Color.new(255, 0, 0)  # red
31+
32
	def bar_color(n)
33
		case n
34
			when 0
35
				return Color.new(0, 0, 0)  # black
36
			when 1
37
				return Color.new(0, 255, 0)  # green
38
			when 2
39-
		health_color = bar_color(1)
39+
				return Color.new(0, 0, 255)  # blue
40
			when 3
41
				return Color.new(255, 0, 0)  # red
42
			when 4
43-
		health = Rect.new(x, y, health_fill, 8)
43+
				return Color.new(255, 255, 255)  # white
44
			when 5
45-
		self.contents.fill_rect(health, health_color)
45+
				return Color.new(230, 230, 230)  # offwhite
46
			when 6
47
				return Color.new(50, 0, 0)  # barely red
48
			when 7
49
				return Color.new(0, 50, 0)  # barely green
50-
		gained_exp = actor.gained_exp(actor.level, exp)
50+
			when 8
51-
		needed_exp = actor.needed_exp(actor.level)
51+
			return Color.new(0, 0, 50)  # barely blue
52
		end
53
	end
54
	
55
56
	def draw_hp_bar(actor, x, y, w = 100)
57
		hp = actor.hp
58
		max_hp = actor.maxhp
59
		border_color = bar_color(0)
60
		health_color1 = bar_color(1)
61
		health_color2 = bar_color(7)
62
		hp_percentage = hp * 1.0 / max_hp
63
		health_fill = w * hp_percentage
64
		border = Rect.new(x - 1, y, w + 2, 10)
65
		self.contents.fill_rect(border, border_color)
66
		if hp > 0
67
			health = self.contents.draw_gradient_rect(x, y + 1, health_fill, 8, health_color1, health_color2)
68
		else
69
			health = Rect.new(x, y, w, 8)
70
			self.contents.fill_rect(health, border_color)
71
		end
72
	end
73
	
74
	def draw_xp_bar(actor, x, y, w = 100)
75
		exp = actor.exp
76
		level = actor.level
77
		gained_exp = actor.gained_exp(exp, level)
78
		needed_exp = actor.needed_exp(level)
79
		exp_percentage = (gained_exp * 1.0 / needed_exp) * w
80
		background_color = bar_color(0)
81
		first_bar_color = bar_color(4)
82
		second_bar_color = bar_color(5)
83
		background_bar = Rect.new(x - 1, y, w + 2, 10)
84
		first_bar = Rect.new(x, y + 1, exp_percentage, 8)
85
		second_bar = Rect.new(x, y + 3, exp_percentage, 4)
86
		self.contents.fill_rect(background_bar, background_color)
87
		self.contents.fill_rect(first_bar, first_bar_color)
88
		self.contents.fill_rect(second_bar, second_bar_color)
89
	end
90
end