扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 121|回复: 0

[转载发布] Vx型Xp用 - Player增强 - Player_Add

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    昨天 18:01
  • 签到天数: 114 天

    连续签到: 4 天

    [LV.6]常住居民II

    2338

    主题

    403

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10632
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13401

    灌水之王

    发表于 2024-4-19 20:29:23 | 显示全部楼层 |阅读模式
    清单:
    领队切换
    惯性行走
    弹性滚动
    八方向键移动



    (如果有其他需要可以回帖(?))

    1. #==============================================================================# ** 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)  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)  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])  endend#==============================================================================# ■ 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  endend复制代码
    复制代码
                 本帖来自P1论坛作者忧雪の伤,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=177264  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-15 07:12 , Processed in 0.141614 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表