赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 13520 |
最后登录 | 2012-11-8 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 0 小时
- 注册时间
- 2006-11-17
- 帖子
- 18
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
- class Bitmap
- #--------------------------------------------------------------------------
- # ● 描绘直线
- # x1,y1,x2,y2: 直线两端的坐标
- # width: 宽度
- # color: 颜色
- #--------------------------------------------------------------------------
- def drawline(x1, y1, x2, y2, width, color)
- x1 = x1.to_f
- y1 = y1.to_f
- x2 = x2.to_f
- y2 = y2.to_f
- width = width.to_f
- k = (y2 - y1) / (x2 - x1)
- if k.abs > 1
- drawline_x(x1, y1, x2, y2, width, color)
- else
- drawline_y(x1, y1, x2, y2, width, color)
- end
- end
- def drawline_x(x1, y1, x2, y2, width, color)
- l = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 * width / (y1 - y2)
- length = l.abs * 2
- k = (x2 - x1) / (y2 - y1) #x=ky+b
- b = x1 - k * y1
- if l > 0
- for ty in y2.to_i..y1.to_i
- tx = ty * k + b
- fill_rect(tx - l, ty, length, 1, color)
- end
- else
- for ty in y1.to_i..y2.to_i
- tx = ty * k + b
- fill_rect(tx + l, ty, length, 1, color)
- end
- end
- end
- def drawline_y(x1, y1, x2, y2, width, color)
- l = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 * width / (x1 - x2)
- height = l.abs * 2
- k = (y2 - y1) / (x2 - x1) #y=kx+b
- b = y1 - k * x1
- if l > 0
- for tx in x2.to_i..x1.to_i
- ty = tx * k + b
- fill_rect(tx, ty - l, 1, height, color)
- end
- else
- for tx in x1.to_i..x2.to_i
- ty = tx * k + b
- fill_rect(tx, ty + l, 1, height, color)
- end
- end
- end
- end
- class Window_Status < Window_Base
- def get_position(x_begin, y_begin, x_end, y_end, percent)
- a = []
- a[0] = x_begin + (x_end - x_begin) * percent
- a[1] = y_begin + (y_end - y_begin) * percent
- return a
- end
- def refresh
- self.contents.clear
- x0 = 60 #图表的坐标
- y0 = 220
- r = 100.0 #图表的大小,友情提示:浮点数后面的.0不要省略了
- h = 3 ** 0.5 * r / 2
- a = [] #六边形的顶点和圆心
- a[0] = [r, h] #圆心
- a[1] = [r / 2, 0.0]
- a[2] = [r * 3 / 2, 0.0]
- a[6] = [0.0, h]
- a[3] = [r * 2, h]
- a[5] = [r / 2, h * 2]
- a[4] = [r * 3 / 2, h * 2]
- for i in a
- i[0] += x0
- i[1] += y0
- end
- self.contents.font.color = system_color
- self.contents.draw_text(a[1][0] - 16 , a[1][1] - 32, 80, 32, "攻")
- self.contents.draw_text(a[2][0] - 4, a[2][1] - 32, 80, 32, "防")
- self.contents.draw_text(a[6][0] - 28, a[6][1] - 16, 80, 32, "力")
- self.contents.draw_text(a[5][0] - 16, a[5][1], 80, 32, "敏")
- self.contents.draw_text(a[4][0] - 4, a[4][1], 80, 32, "速")
- self.contents.draw_text(a[3][0] + 8, a[3][1] - 16, 80, 32, "魔")
- #描绘边框
- for i in 1...a.size
- self.contents.drawline(a[0][0], a[0][1], a[i][0], a[i][1], 1, disabled_color)
- end
- self.contents.drawline(a[1][0], a[1][1], a[2][0], a[2][1], 1, text_color(6))
- self.contents.drawline(a[2][0], a[2][1], a[3][0], a[3][1], 1, text_color(6))
- self.contents.drawline(a[3][0], a[3][1], a[4][0], a[4][1], 1, text_color(6))
- self.contents.drawline(a[4][0], a[4][1], a[5][0], a[5][1], 1, text_color(6))
- self.contents.drawline(a[5][0], a[5][1], a[6][0], a[6][1], 1, text_color(6))
- self.contents.drawline(a[6][0], a[6][1], a[1][0], a[1][1], 1, text_color(6))
- #描绘能力曲线
- b = [] #获取能力值
- b.push(@actor.atk)
- b.push(@actor.pdef)
- b.push(@actor.int)
- b.push(@actor.agi)
- b.push(@actor.dex)
- b.push(@actor.str)
- =begin
- #跟999作比较
- c = []
- for i in 0...b.size
- c[i] = get_position(a[0][0], a[0][1], a[i+1][0], a[i+1][1], b[i] / 999.0)
- end
- for i in 0...c.size
- self.contents.drawline(c[i][0], c[i][1], c[i-1][0], c[i-1][1], 1, text_color(3))
- end
- =end
- #=begin
- #跟最高能力值比较
- max_abi = 0
- b.each{|i| max_abi = [max_abi, i].max}
- max_abi = max_abi.to_f
- c = [] #获得能力值的坐标
- for i in 0...b.size
- c[i] = get_position(a[0][0], a[0][1], a[i+1][0], a[i+1][1], b[i] / max_abi)
- end
- for i in 0...c.size
- self.contents.drawline(c[i][0], c[i][1], c[i-1][0], c[i-1][1], 1, text_color(3))
- end
- #=end
- #描绘能力数值
- self.contents.font.color = knockout_color
- self.contents.font.size = 14
- for i in 0...b.size
- self.contents.draw_text(c[i][0], c[i][1], 32, 24, b[i].to_s)
- end
- self.contents.font.size = 22
- #以下未修改
- draw_actor_graphic(@actor, 40, 112)
- draw_actor_name(@actor, 4, 0)
- draw_actor_class(@actor, 4 + 144, 0)
- draw_actor_level(@actor, 96, 32)
- draw_actor_state(@actor, 96, 64)
- draw_actor_hp(@actor, 96, 112, 172)
- draw_actor_sp(@actor, 96, 144, 172)
- self.contents.font.color = system_color
- self.contents.draw_text(320, 48, 80, 32, "EXP")
- self.contents.draw_text(320, 80, 80, 32, "NEXT")
- self.contents.font.color = normal_color
- self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
- self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(320, 160, 96, 32, "装备")
- draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
- draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
- draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
- draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
- draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
- end
- end
复制代码
效果就是这样的。。。
没有显示人物的魔法防御(不知道七边形怎么画。。。),建议用ps画一个图表,仅使用drawline画能力值的曲线就好,嗯,直线还会有点锯齿,有待改进。
悄悄更新一个抗锯齿的图片,脚本还没写好,过几天再更新
题目有点夸张,改了一个。。。 |
|