方法需要楼主自己调用,可自由定义六边形的边长。
方法:
draw_six(actor,a,x,y,c,s)
draw_six_status(actor,x,y,c,s,bl)
注意:上面两个方法调用缺一不可,并且设置的x,y必须相同
draw_six(actor,a,x,y,c,s)参数:
actor:角色
a:边长
x:六边形中心点的x坐标
y:六边形中心点的y坐标
c:六边形的线条颜色
s:六边形线条的直径
draw_six_status(actor,x,y,c,s,bl)参数
actor:角色
x:能力值不规则图形中心点的x坐标
y:能力值不规则图形中心点的y坐标
c:能力值不规则图形的线条颜色
s:能力值不规则图形的线条直径
bl:能力值图形比率(比如10,就是能力值/10来显示,具体效果可自己尝试)
- class Bitmap
- def draw_line(x, y, dx, dy, color,size)
- return unless x
- mx = x < dx ? 1 : -1
- my = y < dy ? 1 : -1
- dfx, dfy = (dx - x).abs.to_i, (dy - y).abs.to_i
- diff = [dfx, dfy].max / 2
- if dfx >= dfy
- (dfx + 1).times { |i|
- if size == 1
- self.set_pixel(x, y, color)
- else
- self.fill_rect(x, y, size, size, color)
- end
- x += mx
- diff += dfy
- if diff >= dfx
- diff -= dfx
- y += my
- end
- }
- else
- (dfy + 1).times { |i|
- if size == 1
- self.set_pixel(x, y, color)
- else
- self.fill_rect(x, y, size, size, color)
- end
- y += my
- diff += dfx
- if diff >= dfy
- diff -= dfy
- x += mx
- end
- }
- end
- end
- end
- class Window_Base < Window
- def draw_six(actor,a,x,y,c,s)
- x1 = Math.sqrt(3)/2.0*a
- x2 = a/2.0
- contents.draw_line(x,y-a,x+x1,y-x2,c,s)
- contents.draw_line(x+x1,y-x2,x+x1,y+x2,c,s)
- contents.draw_line(x+x1,y+x2,x,y+a,c,s)
- contents.draw_line(x,y+a,x-x1,y+x2,c,s)
- contents.draw_line(x-x1,y+x2,x-x1,y-x2,c,s)
- contents.draw_line(x-x1,y-x2,x,y-a,c,s)
- contents.draw_line(x,y-a,x,y+a,c,s)
- contents.draw_line(x+x1,y-x2,x-x1,y+x2,c,s)
- contents.draw_line(x-x1,y-x2,x+x1,y+x2,c,s)
- draw_text(x-30, y-a-30, 180, line_height, "ATK")
- draw_text(x+x1, y-x2, 180, line_height, "DEF")
- draw_text(x+x1, y+x2, 180, line_height, "INT")
- draw_text(x-30, y+a, 180, line_height, "RES")
- draw_text(x-x1-40, y+x2, 180, line_height, "SPD")
- draw_text(x-x1-40, y-x2, 180, line_height, "LUK")
- draw_actor_paramm(actor,x-30, y-a-30, 2)
- draw_actor_paramm(actor,x+x1, y-x2, 3)
- draw_actor_paramm(actor,x+x1, y+x2, 4)
- draw_actor_paramm(actor,x-30, y+a, 5)
- draw_actor_paramm(actor,x-x1-70, y+x2+30, 6)
- draw_actor_paramm(actor,x-x1-70, y-x2+30, 7)
- end
- def draw_six_status(actor,x,y,c,s,bl)
- a = Math.sqrt(3)/2.0
- b = 1.0/2.0
- contents.draw_line(x,y-actor.atk/bl.to_f,x+a*actor.def/bl.to_f,y-b*actor.def/bl.to_f,c,s)
- contents.draw_line(x+a*actor.def/bl.to_f,y-b*actor.def/bl.to_f,x+a*actor.mat/bl.to_f,y+b*actor.mat/bl.to_f,c,s)
- contents.draw_line(x+a*actor.mat/bl.to_f,y+b*actor.mat/bl.to_f,x,y+actor.mdf/bl.to_f,c,s)
- contents.draw_line(x,y+actor.mdf/bl.to_f,x-a*actor.agi/bl.to_f,y+b*actor.agi/bl.to_f,c,s)
- contents.draw_line(x-a*actor.agi/bl.to_f,y+b*actor.agi/bl.to_f,x-a*actor.luk/bl.to_f,y-b*actor.luk/bl.to_f,c,s)
- contents.draw_line(x-a*actor.luk/bl.to_f,y-b*actor.luk/bl.to_f,x,y-actor.atk/bl.to_f,c,s)
- end
- def draw_actor_paramm(actor, x, y, param_id)
- change_color(normal_color)
- draw_text(x+30, y, 36, line_height, actor.param(param_id), 2)
- end
- end
复制代码 |