赞 | 40 |
VIP | 0 |
好人卡 | 72 |
积分 | 63 |
经验 | 38967 |
最后登录 | 2024-11-5 |
在线时间 | 1481 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6260
- 在线时间
- 1481 小时
- 注册时间
- 2015-7-25
- 帖子
- 652
|
用了个比较笨的方法....肯定是需要修改的....
def draw_six_status(actor,x,y) line_color = Color.new(255,0,0) gauge_back_color = Color.new(255,255,255) contents.fill_rect(x-50, y-50, 100, 2, gauge_back_color) 50.times {|i|contents.fill_rect(x-50-i, y-50+i, 2, 1, gauge_back_color)} 50.times {|i|contents.fill_rect(x-100+i, y+i, 2, 1, gauge_back_color)} contents.fill_rect(x-50, y+50, 100, 2, gauge_back_color) 50.times {|i|contents.fill_rect(x+50+i, y+50-i, 2, 1, gauge_back_color)} 50.times {|i|contents.fill_rect(x+100-i, y-i, 2, 1, gauge_back_color)} actor.atk.times {|i| contents.fill_rect(x+i, y-i, 2, 1, line_color)} (actor.def*2).times {|i| contents.fill_rect(x+i, y, 2, 1, line_color)} actor.mat.times {|i| contents.fill_rect(x+i, y+i, 2, 1, line_color)} actor.mdf.times {|i| contents.fill_rect(x-i, y+i, 2, 1, line_color)} (actor.agi*2).times {|i| contents.fill_rect(x-i, y, 2, 1, line_color)} actor.luk.times {|i| contents.fill_rect(x-i, y-i, 2, 1, line_color)} draw_triangle(x,y,x+actor.atk,y-actor.atk,x+actor.def*2,y) draw_triangle(x,y,x+actor.mat,y+actor.mat,x+actor.def*2,y) draw_triangle(x-actor.mdf,y+actor.mdf,x,y,x+actor.mat,y+actor.mat) draw_triangle(x-actor.agi*2,y,x-actor.mdf,y+actor.mdf,x,y) draw_triangle(x-actor.agi*2,y,x-actor.luk,y-actor.luk,x,y) draw_triangle(x-actor.luk,y-actor.luk,x+actor.atk,y-actor.atk,x,y) end def draw_triangle(x1,y1,x2,y2,x3,y3,color=Color.new(255,0,0,255)) x=0 k1=(y2-y1)*1.0/(x2-x1) k2=(y3-y1)*1.0/(x3-x1) k3=(y3-y2)*1.0/(x3-x2) height=1 for x in x1..x2 y = (x-x1)*k1+y1 height = (x-x1)*k2+y1-y if height < 0 y+=height height = 0 - height end contents.fill_rect(x, y, 1, height, color) end for x in x2..x3 y = (x-x2)*k3+y2 height = (x-x1)*k2+y1-y if height < 0 y+=height height = 0 - height end contents.fill_rect(x, y, 1, height, color) end end
def draw_six_status(actor,x,y)
line_color = Color.new(255,0,0)
gauge_back_color = Color.new(255,255,255)
contents.fill_rect(x-50, y-50, 100, 2, gauge_back_color)
50.times {|i|contents.fill_rect(x-50-i, y-50+i, 2, 1, gauge_back_color)}
50.times {|i|contents.fill_rect(x-100+i, y+i, 2, 1, gauge_back_color)}
contents.fill_rect(x-50, y+50, 100, 2, gauge_back_color)
50.times {|i|contents.fill_rect(x+50+i, y+50-i, 2, 1, gauge_back_color)}
50.times {|i|contents.fill_rect(x+100-i, y-i, 2, 1, gauge_back_color)}
actor.atk.times {|i| contents.fill_rect(x+i, y-i, 2, 1, line_color)}
(actor.def*2).times {|i| contents.fill_rect(x+i, y, 2, 1, line_color)}
actor.mat.times {|i| contents.fill_rect(x+i, y+i, 2, 1, line_color)}
actor.mdf.times {|i| contents.fill_rect(x-i, y+i, 2, 1, line_color)}
(actor.agi*2).times {|i| contents.fill_rect(x-i, y, 2, 1, line_color)}
actor.luk.times {|i| contents.fill_rect(x-i, y-i, 2, 1, line_color)}
draw_triangle(x,y,x+actor.atk,y-actor.atk,x+actor.def*2,y)
draw_triangle(x,y,x+actor.mat,y+actor.mat,x+actor.def*2,y)
draw_triangle(x-actor.mdf,y+actor.mdf,x,y,x+actor.mat,y+actor.mat)
draw_triangle(x-actor.agi*2,y,x-actor.mdf,y+actor.mdf,x,y)
draw_triangle(x-actor.agi*2,y,x-actor.luk,y-actor.luk,x,y)
draw_triangle(x-actor.luk,y-actor.luk,x+actor.atk,y-actor.atk,x,y)
end
def draw_triangle(x1,y1,x2,y2,x3,y3,color=Color.new(255,0,0,255))
x=0
k1=(y2-y1)*1.0/(x2-x1)
k2=(y3-y1)*1.0/(x3-x1)
k3=(y3-y2)*1.0/(x3-x2)
height=1
for x in x1..x2
y = (x-x1)*k1+y1
height = (x-x1)*k2+y1-y
if height < 0
y+=height
height = 0 - height
end
contents.fill_rect(x, y, 1, height, color)
end
for x in x2..x3
y = (x-x2)*k3+y2
height = (x-x1)*k2+y1-y
if height < 0
y+=height
height = 0 - height
end
contents.fill_rect(x, y, 1, height, color)
end
end
|
|