查看: 64|回复: 0

[转载发布] 【范例和脚本】塞尔达传说屏幕卷动,陶笛系统,偷东西系

[复制链接]
  • TA的每日心情
    开心
    2024-5-10 09:55
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元一千年八月三日(秋) | 显示全部楼层 |阅读模式
    作者:黄耀生

    如果只想要屏幕卷动,请往下翻,下面有脚本
    下载地址1不行的话,请翻到3楼,下载地址2
    范例下载地址

    介绍:
    陶笛:迷宫里面使用,就会到迷宫入口;迷宫外部使用,就会到默认传送点(建议只能有一个默认传送点)。
    偷东西:去商店里面,挑选商品后,从商店老板的背后绕过去,离开商店。回到商店就会被商店老板秒杀。
    塞尔达屏幕卷动:触碰屏幕边缘就屏幕就会卷动,增强了区域化的效果。 靠修改Game_player实现。

    截图:







    补充:
    1、已经发现bug,但是修改Game_player即可修复,具体方法看第3点
    2、即使场所移动,屏幕也固定在了一个位置
    3、引用Game_Player脚本代码
    1. #为了实现塞尔达传说碰屏幕边缘就会滚动,#改此脚本改到吐血了……#                             ——黄耀生#==============================================================================# ■ Game_Player#------------------------------------------------------------------------------#  处理主角的类。事件启动的判定、以及地图的滚动等功能。# 本类的实例请参考 $game_player。#==============================================================================class Game_Player < Game_Character  #--------------------------------------------------------------------------  # ● 恒量  #--------------------------------------------------------------------------  CENTER_X = (320 - 16) * 4   # 画面中央的 X 坐标 * 4  CENTER_Y = (240 - 16) * 4   # 画面中央的 Y 坐标 * 4  #--------------------------------------------------------------------------  # ● 可以通行判定  #     x : X 坐标  #     y : Y 坐标  #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)  #--------------------------------------------------------------------------  def passable?(x, y, d)    # 求得新的坐标    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)    # 坐标在地图外的情况下    unless $game_map.valid?(new_x, new_y)      # 不能通行      return false    end    # 调试模式为 ON 并且 按下 CTRL 键的情况下    if $DEBUG and Input.press?(Input::CTRL)      # 可以通行      return true    end    super  end  #--------------------------------------------------------------------------  # ● 像通到画面中央一样的设置地图的显示位置  #--------------------------------------------------------------------------  def center(x, y)    max_x = ($game_map.width - 20) * 128    max_y = ($game_map.height - 15) * 128    $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max    $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max  end  #--------------------------------------------------------------------------  # ● 向指定的位置移动  #     x : X 座標  #     y : Y 座標  #--------------------------------------------------------------------------  def moveto(x, y)    super    # 自连接    center(x, y)    # 生成遇敌计数    make_encounter_count  end  #--------------------------------------------------------------------------  # ● 增加步数  #--------------------------------------------------------------------------  def increase_steps    super    # 不是强制移动路线的场合    unless @move_route_forcing      # 增加步数      $game_party.increase_steps      # 步数是偶数的情况下      if $game_party.steps % 2 == 0        # 检查连续伤害        $game_party.check_map_slip_damage      end    end  end  #--------------------------------------------------------------------------  # ● 获取遇敌计数  #--------------------------------------------------------------------------  def encounter_count    return @encounter_count  end  #--------------------------------------------------------------------------  # ● 生成遇敌计数  #--------------------------------------------------------------------------  def make_encounter_count    # 两种颜色震动的图像    if $game_map.map_id != 0      n = $game_map.encounter_step      @encounter_count = rand(n) + rand(n) + 1    end  end  #--------------------------------------------------------------------------  # ● 刷新  #--------------------------------------------------------------------------  def refresh    # 同伴人数为 0 的情况下    if $game_party.actors.size == 0      # 清除角色的文件名及对像      @character_name = ""      @character_hue = 0      # 分支结束      return    end    # 获取带头的角色    actor = $game_party.actors[0]    # 设置角色的文件名及对像    @character_name = actor.character_name    @character_hue = actor.character_hue    # 初始化不透明度和合成方式子    @opacity = 255    @blend_type = 0  end  #--------------------------------------------------------------------------  # ● 同位置的事件启动判定  #--------------------------------------------------------------------------  def check_event_trigger_here(triggers)    result = false    # 事件执行中的情况下    if $game_system.map_interpreter.running?      return result    end    # 全部事件的循环    for event in $game_map.events.values      # 事件坐标与目标一致的情况下      if event.x == @x and event.y == @y and triggers.include?(event.trigger)        # 跳跃中以外的情况下、启动判定是同位置的事件        if not event.jumping? and event.over_trigger?          event.start          result = true        end      end    end    return result  end  #--------------------------------------------------------------------------  # ● 正面事件的启动判定  #--------------------------------------------------------------------------  def check_event_trigger_there(triggers)    result = false    # 事件执行中的情况下    if $game_system.map_interpreter.running?      return result    end    # 计算正面坐标    new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)    new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)    # 全部事件的循环    for event in $game_map.events.values      # 事件坐标与目标一致的情况下      if event.x == new_x and event.y == new_y and         triggers.include?(event.trigger)        # 跳跃中以外的情况下、启动判定是正面的事件        if not event.jumping? and not event.over_trigger?          event.start          result = true        end      end    end    # 找不到符合条件的事件的情况下    if result == false      # 正面的元件是计数器的情况下      if $game_map.counter?(new_x, new_y)        # 计算 1 元件里侧的坐标        new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)        new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)        # 全事件的循环        for event in $game_map.events.values          # 事件坐标与目标一致的情况下          if event.x == new_x and event.y == new_y and             triggers.include?(event.trigger)            # 跳跃中以外的情况下、启动判定是正面的事件            if not event.jumping? and not event.over_trigger?              event.start              result = true            end          end        end      end    end    return result  end  #--------------------------------------------------------------------------  # ● 接触事件启动判定  #--------------------------------------------------------------------------  def check_event_trigger_touch(x, y)    result = false    # 事件执行中的情况下    if $game_system.map_interpreter.running?      return result    end    # 全事件的循环    for event in $game_map.events.values      # 事件坐标与目标一致的情况下      if event.x == x and event.y == y and [1,2].include?(event.trigger)        # 跳跃中以外的情况下、启动判定是正面的事件        if not event.jumping? and not event.over_trigger?          event.start          result = true        end      end    end    return result  end  #--------------------------------------------------------------------------  # ● 画面更新  #--------------------------------------------------------------------------  def update    # 本地变量记录移动信息    last_moving = moving?    # 移动中、事件执行中、强制移动路线中、    # 信息窗口一个也不显示的时候    unless moving? or $game_system.map_interpreter.running? or           @move_route_forcing or $game_temp.message_window_showing      # 如果方向键被按下、主角就朝那个方向移动      case Input.dir4      when 2        move_down        @linkx = 0        @linky = 0        @linkx = $game_player.x        @linky = $game_player.y        #记录坐标        $game_map.scroll_left(@linkx*128)        $game_map.scroll_up(@linky*128)        #画面卷动        @linkx = ($game_player.x/20).to_i        @linky = ($game_player.y/15).to_i        #记录坐标        $game_map.scroll_right(@linkx*128*20)        $game_map.scroll_down(@linky*128*15)        #画面卷动      when 4        move_left        @linkx = 0        @linky = 0        @linkx = $game_player.x        @linky = $game_player.y        #记录坐标        $game_map.scroll_left(@linkx*128)        $game_map.scroll_up(@linky*128)        #画面卷动        @linkx = ($game_player.x/20).to_i        @linky = ($game_player.y/15).to_i        #记录坐标        $game_map.scroll_right(@linkx*128*20)        $game_map.scroll_down(@linky*128*15)        #画面卷动      when 6        move_right        @linkx = 0        @linky = 0        @linkx = $game_player.x        @linky = $game_player.y        #记录坐标        $game_map.scroll_left(@linkx*128)        $game_map.scroll_up(@linky*128)        #画面卷动        @linkx = ($game_player.x/20).to_i        @linky = ($game_player.y/15).to_i        #记录坐标        $game_map.scroll_right(@linkx*128*20)        $game_map.scroll_down(@linky*128*15)        #画面卷动      when 8        move_up        @linkx = 0        @linky = 0        @linkx = $game_player.x        @linky = $game_player.y        #记录坐标        $game_map.scroll_left(@linkx*128)        $game_map.scroll_up(@linky*128)        #画面卷动        @linkx = ($game_player.x/20).to_i        @linky = ($game_player.y/15).to_i        #记录坐标        $game_map.scroll_right(@linkx*128*20)        $game_map.scroll_down(@linky*128*15)        #画面卷动      end    end    # 本地变量记忆坐标    last_real_x = @real_x    last_real_y = @real_y    super    # 角色向下移动、画面上的位置在中央下方的情况下    # 不在移动中的情况下    unless moving?      # 上次主角移动中的情况      if last_moving        # 与同位置的事件接触就判定为事件启动        result = check_event_trigger_here([1,2])        # 没有可以启动的事件的情况下        if result == false          # 调试模式为 ON 并且按下 CTRL 键的情况下除外          unless $DEBUG and Input.press?(Input::CTRL)            # 遇敌计数下降            if @encounter_count > 0              @encounter_count -= 1            end          end        end      end      # 按下 C 键的情况下      if Input.trigger?(Input::C)        # 判定为同位置以及正面的事件启动        check_event_trigger_here([0])        check_event_trigger_there([0,1,2])      end    end  endend#请覆盖原来的Game_Player,避免出现脚本已备份#link的意思是塞尔达传说里面的link……复制代码
    复制代码
                 本帖来自P1论坛作者hys111111,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=220338  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-5-20 20:41 , Processed in 0.073955 second(s), 47 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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