注册会员 登录
Project1 返回首页

鼠窝 https://rpg.blue/?335626 [收藏] [复制] [分享] [RSS] ~外站脚本图书馆~

日志

简单的跳跃系统

已有 340 次阅读2014-5-18 13:36 |个人分类:外站脚本

#--------------------------------------------------------------#
# SIMPLE JUMP SYSTEM
#--------------------------------------------------------------#
# Give you the ability to jump over some objetcs and holes,
# avoiding on walk over events conditions, etc.
#--------------------------------------------------------------#
# Author.......: Maloke
# Version......: 1.5
# Launch.......: 01/13/2013
# Last Update..: 01/16/2013
#--------------------------------------------------------------#
# [?] Instructions:
#
# 1. Make a switch to activate it
#
# 2. Hold the direction you want to jump, then press the button
# A of your keyboard, or the custom key (if you have configured)
#--------------------------------------------------------------#
# Special thanks to Galv
#--------------------------------------------------------------#
module MK_SJS
#--------------------------------------------------------------#
# [%] Settings
#--------------------------------------------------------------#
  JUMP_SWITCH = 1      #If this is on the jump works
  JUMP_SOUND = "Jump1"  #Play this SE if you jump
  JUMP_DELAY = 30      #Frame delay between jumps
  JUMP_TRIGGER = :X    #Set a custom bustom for jump
#--------------------------------------------------------------#
end
#--------------------------------------------------------------#
# [!] Code
#--------------------------------------------------------------#
# Warning: I do not recomend editting below this if you don't
# know what you are doing.
#--------------------------------------------------------------#
class Game_Player < Game_Character
#--------------------------------------------------------------#
# * Alias methods
#--------------------------------------------------------------#
  alias mk_update update
  alias mk_move_by_input move_by_input
  alias mk_init initialize
#--------------------------------------------------------------#
# * Defines the delay between jumps
#--------------------------------------------------------------#
  def initialize
    mk_init
    @jump_delay = MK_SJS::JUMP_DELAY
  end
#--------------------------------------------------------------#
# * Will check the jump_priority [Bug Fix]
#--------------------------------------------------------------#
  def update
    mk_update
    jump_priority
  end
#--------------------------------------------------------------#
# * Verify if the Switch is on then verify if the delay is
# still charging after this, is ready for jump, and when you
# do it jump and reset the delay
#--------------------------------------------------------------#
  def move_by_input
    mk_move_by_input
    if $game_switches[MK_SJS::JUMP_SWITCH] == true
    if @jump_delay == MK_SJS::JUMP_DELAY
      if Input.trigger?(MK_SJS::JUMP_TRIGGER)
        jump_extra if do_jump
        @jump_delay = 0
      end
    else
      @jump_delay += 1
    end
    end
  end
#--------------------------------------------------------------#
# * Check every passability possible [Bug Fix]
#--------------------------------------------------------------# 
  def check_map_passability(mkx, mky)
    if map_passable?(mkx, mky, 2) or map_passable?(mkx, mky, 4) or map_passable?(mkx, mky, 6) or map_passable?(mkx, mky, 8)
      return true
    else
      return false
    end
  end
#--------------------------------------------------------------#
# * 2 -> Your hero will be over everthing
# 1 -> Your hero is normal
#--------------------------------------------------------------#
  def jump_priority
    if jumping?
      @priority_type = 2
    else
      @priority_type = 1
    end
  end
#--------------------------------------------------------------#
# * Check if there are any tile of 2 height in your way
#--------------------------------------------------------------#
  def check_layered(mk_cl_x, mk_cl_y)
    mk_tile_check = "[0, 0, "+$game_map.tile_id(mk_cl_x, mk_cl_y, 0x00).to_s+"]"
    mk_layered_check = $game_map.layered_tiles(mk_cl_x, mk_cl_y).to_s
    else if mk_tile_check == mk_layered_check
      return true
    else
      return false
    end
  end
#--------------------------------------------------------------#
# * Make you followers jump with you, and play the SE
#--------------------------------------------------------------# 
  def jump_extra
    @followers.each {|member| member.jump(@x - member.x, @y - member.y)}
    Audio.se_play('Audio/SE/'+MK_SJS::JUMP_SOUND+'.ogg',50,150)
  end
#--------------------------------------------------------------#
# * Do the jump only if everything is all right
#--------------------------------------------------------------#
  def do_jump
    case @direction
    when 2
      if !collide_with_events?(@x, @y+2) && check_map_passability(@x, @y+2)
        if normal_walk? && check_layered(@x, @y)
          jump( 0, 2)
        end
      end
    when 4
      if !collide_with_events?(@x-2, @y) && check_map_passability(@x-2, @y)
        if normal_walk? && check_layered(@x-1, @y-1)
          jump(-2, 0)
        end
      end
    when 6
      if !collide_with_events?(@x+2, @y) && check_map_passability(@x+2, @y)
        if normal_walk? && check_layered(@x+1, @y-1)
          jump( 2, 0)
        end
      end
    when 8
      if !collide_with_events?(@x, @y-2) && check_map_passability(@x, @y-2)
        if normal_walk? && check_layered(@x, @y-2)
          jump( 0,-2)
        end
      end
    end
  end
#--------------------------------------------------------------#
# * End of Class
#--------------------------------------------------------------#
end
#--------------------------------------------------------------#
# * Script End
#--------------------------------------------------------------#

鸡蛋

鲜花

评论 (0 个评论)

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 19:10

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部