- 注册时间
- 2007-4-5
- 最后登录
- 2008-5-18
⑤进阶
- 积分
- 574
|

楼主 |
发表于 2007-12-5 21:41:06
|
显示全部楼层
###########################################################################
# 画我方HP条
# 设计by盗帅冬瓜,颜色渐变法by樱雅在土(没这个就很难画出渐变色)
###########################################################################
def draw_hp_barforactor(actor,x,y)
width = 108
black = Color.new(0,0,0,200)
black2 = Color.new(0,0,0,100)
#RP颜色计算法
val = 255 * ((actor.hp*100)/actor.maxhp)
green = 0 + val/100
val2 = 255 * ((actor.hp*100)/actor.maxhp)
red2 = 255 - val2/100
green2 = 0 + val2/100
startcolor = Color.new(red2,green2,0,150)
endcolor = Color.new(255,green,0,150)
w = width * actor.hp / actor.maxhp
#黑色倒影
draw_line(x+4, y+18, x+width+4, y+18, black, 7, black2)
#画血条(横板渐变色,颜色变化法由樱雅在土提供)
draw_line(x, y+14, x+w, y+14, startcolor, 7, endcolor)
#写上HP两个大字,顺便表示HP的数值。
self.contents.font.size = 20
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(x, y, 68, 32, actor.hp.to_s, 2)
self.contents.font.color = normal_color
self.contents.draw_text(x + 68, y, 12, 32, "/", 1)
self.contents.draw_text(x + 80, y, 48, 32, actor.maxhp.to_s)
self.contents.font.size = 22
end
###########################################################################
# 画我方SP条
# 设计by盗帅冬瓜,颜色渐变法by樱雅在土(没这个就很难画出渐变色)
###########################################################################
def draw_sp_barforactor(actor,x,y)
width = 108
black = Color.new(0,0,0,200)
black2 = Color.new(0,0,0,100)
startcolor = Color.new(0,0,255,150)
endcolor = Color.new(0,255,255,150)
w = width * actor.sp / actor.maxsp
#黑色倒影
draw_line(x+4, y+18, x+width+4, y+18, black, 7, black2)
#画气条(横板渐变色,颜色变化法由樱雅在土提供)
draw_line(x, y+14, x+w, y+14, startcolor, 7, endcolor)
#写上SP两个大字,顺便表示SP的数值。
self.contents.font.size = 20
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(x, y, 68, 32, actor.sp.to_s, 2)
self.contents.font.color = normal_color
self.contents.draw_text(x + 68, y, 12, 32, "/", 1)
self.contents.draw_text(x + 80, y, 48, 32, actor.maxsp.to_s)
self.contents.font.size = 22
end
#--------------------------------------------------------------------------
# ● ライン描画 by 桜雅 在土
#--------------------------------------------------------------------------
def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
# 描写距離の計算。大きめに直角時の長さ。
distance = (start_x - end_x).abs + (start_y - end_y).abs
# 描写開始
if end_color == start_color
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
if width == 1
self.contents.set_pixel(x, y, start_color)
else
self.contents.fill_rect(x, y, width, width, start_color)
end
end
else
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
r = start_color.red * (distance-i)/distance + end_color.red * i/distance
g = start_color.green * (distance-i)/distance + end_color.green * i/distance
b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
if width == 1
self.contents.set_pixel(x, y, Color.new(r, g, b, a))
else
self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
end
end
end
end
###########################################################################
这个脚本怎么用 我看了半天 新建类也不行 改WINDOW_HELP也不行 帮帮忙吧 |
|