Project1
标题:
[新手自制]根据血量绿黄红渐变的血条
[打印本页]
作者:
alwing
时间:
2008-1-15 23:36
标题:
[新手自制]根据血量绿黄红渐变的血条
看了“七夕小雨”的教程http://rpg.blue/web/htm/news756.htm
有了一个血条绿黄红渐变的思路,自己写了一个脚本,希望高手指教一下。
原理就是做一个条件分歧
满血时红色最低,绿色最高
当超过半血的情况,红色随血的减少而增加,直到和绿色相等为止
当低于半血的情况,绿色随血的减少而减少,直到最低
附上色表一张:
使用方法:把Window_BattleStatus替换为以下脚本
#==============================================================================
# ■ 小翼(alwing)特制 HP MP 显示槽↓↓↓↓
#==============================================================================
# HP定义
def HP(actor,x,y,w=94)
#底色定义
self.contents.fill_rect(x+26, y+14, w+4,12, Color.new(0,0,0,255))
self.contents.fill_rect(x+27, y+15, w+2,10, Color.new(255,255,255,255))
self.contents.fill_rect(x+28, y+16, w,8, Color.new(0,0,0,255))
#HP宽度定义
@HPw = w * actor.hp/actor.maxhp
#中
if actor.hp > actor.maxhp/2
@HPcg = 255
@HPcr = 150 + 105 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr = 255
@HPcg = 150 + 105 * actor.hp/(actor.maxhp/2)
end
#中偏边
if actor.hp > actor.maxhp/2
@HPcg1 = 255
@HPcr1 = 100 + 155 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr1 = 255
@HPcg1 = 100 + 155 * actor.hp/(actor.maxhp/2)
end
#边偏中
if actor.hp > actor.maxhp/2
@HPcg2 = 200
@HPcr2 = 50 + 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr2 = 200
@HPcg2 = 50 + 150 * actor.hp/(actor.maxhp/2)
end
#边
if actor.hp > actor.maxhp/2
@HPcg3 = 150
@HPcr3 = 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr3 = 150
@HPcg3 = 150 * actor.hp/(actor.maxhp/2)
end
#HP条定义
self.contents.fill_rect(x+28, y+16, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
self.contents.fill_rect(x+28, y+17, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
self.contents.fill_rect(x+28, y+18, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
#中
self.contents.fill_rect(x+28, y+19, @HPw,2, Color.new(@HPcr,@HPcg,150,255))
#中偏边
self.contents.fill_rect(x+28, y+21, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
#边偏中
self.contents.fill_rect(x+28, y+22, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
#边
self.contents.fill_rect(x+28, y+23, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
end
# MP定义
def MP(actor,x,y,w=94)
self.contents.fill_rect(x+26, y+46, w+4,12, Color.new(0,0,0,255))
self.contents.fill_rect(x+27, y+47, w+2,10, Color.new(255,255,255,255))
self.contents.fill_rect(x+28, y+48, w,8, Color.new(0,0,0,255))
@MPw = w * actor.sp/actor.maxsp
self.contents.fill_rect(x+28, y+48, @MPw,1, Color.new(0,0,150,255))
self.contents.fill_rect(x+28, y+49, @MPw,1, Color.new(50,50,200,255))
self.contents.fill_rect(x+28, y+50, @MPw,1, Color.new(100,100,255,255))
self.contents.fill_rect(x+28, y+51, @MPw,2, Color.new(150,150,255,255))#中
self.contents.fill_rect(x+28, y+53, @MPw,1, Color.new(100,100,255,255))
self.contents.fill_rect(x+28, y+54, @MPw,1, Color.new(50,50,200,255))
self.contents.fill_rect(x+28, y+55, @MPw,1, Color.new(0,0,150,255))
end
#==============================================================================
# ■ 小翼(alwing)特制 HP MP 显示槽↑↑↑
#==============================================================================
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
# 显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = [false, false, false, false]
refresh
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# ● 设置升级标志
# actor_index : 角色索引
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
HP(actor,actor_x,32)
MP(actor,actor_x,32)
draw_actor_hp(actor, actor_x, 32, 120)
draw_actor_sp(actor, actor_x, 64, 120)
if @level_up_flags[i]
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
else
draw_actor_state(actor, actor_x, 96)
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 主界面的不透明度下降
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
end
end
end
复制代码
作者:
alwing
时间:
2008-1-15 23:36
标题:
[新手自制]根据血量绿黄红渐变的血条
看了“七夕小雨”的教程http://rpg.blue/web/htm/news756.htm
有了一个血条绿黄红渐变的思路,自己写了一个脚本,希望高手指教一下。
原理就是做一个条件分歧
满血时红色最低,绿色最高
当超过半血的情况,红色随血的减少而增加,直到和绿色相等为止
当低于半血的情况,绿色随血的减少而减少,直到最低
附上色表一张:
使用方法:把Window_BattleStatus替换为以下脚本
#==============================================================================
# ■ 小翼(alwing)特制 HP MP 显示槽↓↓↓↓
#==============================================================================
# HP定义
def HP(actor,x,y,w=94)
#底色定义
self.contents.fill_rect(x+26, y+14, w+4,12, Color.new(0,0,0,255))
self.contents.fill_rect(x+27, y+15, w+2,10, Color.new(255,255,255,255))
self.contents.fill_rect(x+28, y+16, w,8, Color.new(0,0,0,255))
#HP宽度定义
@HPw = w * actor.hp/actor.maxhp
#中
if actor.hp > actor.maxhp/2
@HPcg = 255
@HPcr = 150 + 105 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr = 255
@HPcg = 150 + 105 * actor.hp/(actor.maxhp/2)
end
#中偏边
if actor.hp > actor.maxhp/2
@HPcg1 = 255
@HPcr1 = 100 + 155 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr1 = 255
@HPcg1 = 100 + 155 * actor.hp/(actor.maxhp/2)
end
#边偏中
if actor.hp > actor.maxhp/2
@HPcg2 = 200
@HPcr2 = 50 + 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr2 = 200
@HPcg2 = 50 + 150 * actor.hp/(actor.maxhp/2)
end
#边
if actor.hp > actor.maxhp/2
@HPcg3 = 150
@HPcr3 = 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
else
@HPcr3 = 150
@HPcg3 = 150 * actor.hp/(actor.maxhp/2)
end
#HP条定义
self.contents.fill_rect(x+28, y+16, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
self.contents.fill_rect(x+28, y+17, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
self.contents.fill_rect(x+28, y+18, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
#中
self.contents.fill_rect(x+28, y+19, @HPw,2, Color.new(@HPcr,@HPcg,150,255))
#中偏边
self.contents.fill_rect(x+28, y+21, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
#边偏中
self.contents.fill_rect(x+28, y+22, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
#边
self.contents.fill_rect(x+28, y+23, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
end
# MP定义
def MP(actor,x,y,w=94)
self.contents.fill_rect(x+26, y+46, w+4,12, Color.new(0,0,0,255))
self.contents.fill_rect(x+27, y+47, w+2,10, Color.new(255,255,255,255))
self.contents.fill_rect(x+28, y+48, w,8, Color.new(0,0,0,255))
@MPw = w * actor.sp/actor.maxsp
self.contents.fill_rect(x+28, y+48, @MPw,1, Color.new(0,0,150,255))
self.contents.fill_rect(x+28, y+49, @MPw,1, Color.new(50,50,200,255))
self.contents.fill_rect(x+28, y+50, @MPw,1, Color.new(100,100,255,255))
self.contents.fill_rect(x+28, y+51, @MPw,2, Color.new(150,150,255,255))#中
self.contents.fill_rect(x+28, y+53, @MPw,1, Color.new(100,100,255,255))
self.contents.fill_rect(x+28, y+54, @MPw,1, Color.new(50,50,200,255))
self.contents.fill_rect(x+28, y+55, @MPw,1, Color.new(0,0,150,255))
end
#==============================================================================
# ■ 小翼(alwing)特制 HP MP 显示槽↑↑↑
#==============================================================================
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
# 显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = [false, false, false, false]
refresh
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# ● 设置升级标志
# actor_index : 角色索引
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
HP(actor,actor_x,32)
MP(actor,actor_x,32)
draw_actor_hp(actor, actor_x, 32, 120)
draw_actor_sp(actor, actor_x, 64, 120)
if @level_up_flags[i]
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
else
draw_actor_state(actor, actor_x, 96)
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 主界面的不透明度下降
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
end
end
end
复制代码
作者:
kk688005
时间:
2008-1-16 02:55
我以前似乎弄过一个2条血的血条
作者:
精灵使者
时间:
2008-1-16 03:28
以前清爽版血条似乎就是渐变的呢。
你可以修改一下sp从蓝到深绿的渐变。
作者:
水迭澜
时间:
2008-1-16 03:33
这个血条满好看的啊
顺便膜拜LZ的头像
作者:
Eclair
时间:
2008-1-16 03:52
提示:
作者被禁止或删除 内容自动屏蔽
作者:
alwing
时间:
2008-1-16 09:24
是啊,我也是在动画中拉条子看颜色的,基本原理就是
绿 + 红 = 黄 (R,G,B,255) R=G
作者:
风吹过的晴天
时间:
2008-1-17 07:21
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1