真·可乐 发表于 2021-3-10 17:51
自己在自己的坑里实现过类似的,但是又改回长条了。和长条血条实现的方式差不多 ...
enghao_lim 发表于 2021-3-10 18:24
老实说,这种血条在rmxp不常看到主要两个原因。
1. 曲型血条真的不好画,需要对一些几何方程+rmxp bitmap熟 ...
#-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = 64 y = i * 116 actor = $game_party.actors[i] draw_actor_graphic(actor, x - 40, y + 80) draw_actor_name(actor, x, y) draw_actor_class(actor, x + 144, y) draw_actor_level(actor, x, y + 32) draw_actor_state(actor, x + 90, y + 32) draw_actor_exp(actor, x, y + 64) draw_actor_hp(actor, x + 236, y + 32) draw_actor_sp(actor, x + 236, y + 64) outer = 50 # 外径 inner = 40 # 内径 ox = 300 # 血条ox oy = i * 116 + 50 # 血条oy hp_rate = actor.hp * 100.0 / actor.maxhp # HP 比例 sp_rate = actor.sp * 100.0 / actor.maxsp # SP 比例 hx_rate = hp_rate == 50 ? 0.0 : Math.tan((0.5 + hp_rate * 0.01) * Math::PI) sx_rate = sp_rate == 50 ? 0.0 : Math.tan((0.5 - sp_rate * 0.01) * Math::PI) hp_color = Color.new(232,90,90,255) sp_color = Color.new(90,90,232,255) outer.downto(-outer) do |by| fy = by.to_f x_in = (fy.abs >= inner ? 0 : inner * Math.sqrt([1 - (fy / inner) ** 2, 0].max)+0.5).to_i x_out = (outer * Math.sqrt([1 - (fy / outer) ** 2, 0].max)+0.5).to_i if by == 0 if hp_rate >= 50 contents.fill_rect(ox - x_out, oy, x_out - x_in, 1, hp_color) end if sp_rate >= 50 contents.fill_rect(ox + x_in, oy, x_out - x_in, 1, sp_color) end next end hx = hx_rate == 0.0 ? -999 * by : (fy / hx_rate).to_i sx = sx_rate == 0.0 ? 999 * by : (fy / sx_rate).to_i if hx.between?(-x_out, -x_in) if hp_rate >= 50 contents.fill_rect(ox - x_out, oy + by, hx + x_out, 1, hp_color) else contents.fill_rect(ox + hx, oy + by, -x_in - hx, 1, hp_color) end elsif (hx > -x_in) ^ (hp_rate <= 50) contents.fill_rect(ox - x_out, oy + by, x_out - x_in, 1, hp_color) end if sx.between?(x_in, x_out) if sp_rate >= 50 contents.fill_rect(ox + sx, oy + by, x_out - sx, 1, sp_color) else contents.fill_rect(ox + x_in, oy + by, sx - x_in, 1, sp_color) end elsif (sx < x_in) ^ (sp_rate <= 50) contents.fill_rect(ox + x_in, oy + by, x_out - x_in, 1, sp_color) end end end end
Project7 - 40 FPS 2021_3_11 1_58_51.png (259.21 KB, 下载次数: 28)
RPGzh500223 发表于 2021-3-12 08:33
重新换种算法,写起来很简单,总的效率差不多,但牺牲了些精度,不太适合渐变色
11楼的方法,逐行描绘,颜 ...
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |