Project1
标题:
Vx型Xp用 - Player增强 - Player_Add
[打印本页]
作者:
忧雪の伤
时间:
2011-5-2 11:43
标题:
Vx型Xp用 - Player增强 - Player_Add
本帖最后由 忧雪の伤 于 2011-5-6 20:35 编辑
清单:
领队切换
惯性行走
弹性滚动
八方向键移动
(如果有其他需要可以回帖(?))
#==============================================================================
# ** Player_Add
#==============================================================================
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● 常量
#--------------------------------------------------------------------------
TRUE_SPEED = 4
BEGIN_SPEED = 2
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@character_name = ""
@character_hue = 0
return if $game_party.actors.size.zero?
@leader_id = 0 if @leader_id.nil? or $game_party.actors[@leader_id].nil?
actor = $game_party.actors[@leader_id]
@character_name = actor.character_name
@character_hue = actor.character_hue
end
#--------------------------------------------------------------------------
# ● 更新惯性
#--------------------------------------------------------------------------
def update_inertia
return @move_speed = BEGIN_SPEED if Input.dir8 == 0
return @move_speed += 0.5 if @move_speed < TRUE_SPEED
end
#--------------------------------------------------------------------------
# ● 更新领队切换
#--------------------------------------------------------------------------
def update_captain
@leader_id += 1 if Input.trigger?(Input::R)
@leader_id -= 1 if Input.trigger?(Input::L)
refresh if Input.trigger?(Input::L) or Input.trigger?(Input::R)
end
#--------------------------------------------------------------------------
# ● 方向键移动处理
#--------------------------------------------------------------------------
def move_by_input
return unless movable?
return if $game_system.map_interpreter.running?
case Input.dir8
when 2; move_down
when 4; move_left
when 6; move_right
when 8; move_up
when 1; move_lower_left
when 3; move_lower_right
when 7; move_upper_left
when 9; move_upper_right
end
update_inertia
end
#--------------------------------------------------------------------------
# ● 可以行动判定
#--------------------------------------------------------------------------
def movable?
return false if moving?
return false if @move_route_forcing
return false if $game_temp.message_window_showing
return true
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
update_captain
last_real_x = @real_x
last_real_y = @real_y
last_moving = moving?
move_by_input
super
update_scroll(last_real_x, last_real_y)
update_nomoving(last_moving)
end
#--------------------------------------------------------------------------
# ● 更新滚动
#--------------------------------------------------------------------------
def update_scroll(last_real_x, last_real_y)
ax1 = $game_map.adjust_x(last_real_x)
ay1 = $game_map.adjust_y(last_real_y)
ax2 = $game_map.adjust_x(@real_x)
ay2 = $game_map.adjust_y(@real_y)
slowmove = (2 ** (@move_speed - 1)).to_i
fastmove = (2 ** @move_speed).to_i
length = (2 ** (@move_speed + 4)).to_i
if ax2 < CENTER_X - 8
if (ax2 - CENTER_X) <= -length
$game_map.scroll_left(fastmove)
else
$game_map.scroll_left(slowmove)
end
elsif ax2 > CENTER_X + 8
if (ax2 - CENTER_X) >= length
$game_map.scroll_right(fastmove)
else
$game_map.scroll_right(slowmove)
end
end
if ay2 < CENTER_Y - 8
if (ay2 - CENTER_Y) <= -length
$game_map.scroll_up(fastmove)
else
$game_map.scroll_up(slowmove)
end
elsif ay2 > CENTER_Y + 8
if (ay2 - CENTER_Y) >= length
$game_map.scroll_down(fastmove)
else
$game_map.scroll_down(slowmove)
end
end
end
#--------------------------------------------------------------------------
# ● 非移动中更新
# last_moving : 之前是否正在移动
#--------------------------------------------------------------------------
def update_nomoving(last_moving)
return if $game_system.map_interpreter.running?
return if moving?
return if check_touch_event if last_moving
if not $game_temp.message_window_showing and Input.trigger?(Input::C)
return if check_action_event
end
update_encounter if last_moving
end
#--------------------------------------------------------------------------
# ● 更新遇敌
#--------------------------------------------------------------------------
def update_encounter
return if $DEBUG and Input.press?(Input::CTRL)
if $game_map.bush?(@x, @y)
@encounter_count -= 2
else
@encounter_count -= 1
end
end
#--------------------------------------------------------------------------
# ● 判断事件是否由接触触发(重叠)
#--------------------------------------------------------------------------
def check_touch_event
return check_event_trigger_here([1,2])
end
#--------------------------------------------------------------------------
# ● 判断事件是否由确认键触发
#--------------------------------------------------------------------------
def check_action_event
return true if check_event_trigger_here([0])
return check_event_trigger_there([0,1,2])
end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 处理地图的类。包含卷动以及可以通行的判断功能。本类的实例请参考 $game_map 。
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 计算 X 座标减去显示座标
# x : X 座标
#--------------------------------------------------------------------------
def adjust_x(x)
return x - @display_x
end
#--------------------------------------------------------------------------
# ● 计算 Y 座标减去显示座标
# y : Y 座标
#--------------------------------------------------------------------------
def adjust_y(y)
return y - @display_y
end
end
复制代码
作者:
蔚蔚小君
时间:
2011-5-2 12:01
提示:
作者被禁止或删除 内容自动屏蔽
作者:
summer92
时间:
2011-5-2 16:16
哇,好啊~~~,大人能不能来个 VX战斗中换人版
作者:
winsonzhong
时间:
2011-10-31 13:06
本帖最后由 winsonzhong 于 2011-11-2 13:20 编辑
又测试了下,发现如果画面卷动速度低于“begin speed"时是无法卷动的,而高于这个速度画面卷动时则可以,但是实际卷动距离只有定义的1/2,并且卷动完后,画面又自动锁定回角色恒定位置(角色位于画面中央)那里,这个怎么解决呢?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1