Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ╔══════════════════════════════════╗
- # ║ ▼ Dark's Free Jumping System ║
- # ║ ▼ Author: Nhat Nguyen (Dark Sky) ║
- # ║ ▼ Release Date: March 16th 2016 ║
- # ║ ▼ Forum: TaoTroChoi.com ║
- # ╚══════════════════════════════════╝
- #-------------------------------------------------------------------------------
- # Version 1.0: Release!
- #-------------------------------------------------------------------------------
- # Free to everyone!
- #-------------------------------------------------------------------------------
- # Yêu cầu: None
- #-------------------------------------------------------------------------------
- # Chức năng:
- # + Có thể điều chỉnh cự ly nhảy của nhân vật.
- # + Không thể nhảy vào các khu vực không cho phép cũng như ra khỏi map.
- #-------------------------------------------------------------------------------
- # Script call: None
- #===============================================================================
- module DarkSky_Jumping
- NORMAL_JUMP_DISTANNCE = 3 # Số ô nhảy qua được
- DASH_JUMP_DISTANNCE = 3 # Số ô nhảy qua được khi chạy
- JUMP_KEY = :Z # Phím D.
- end
- class Spriteset_Map
- include DarkSky_Jumping
- #-----------------------------------------------------------------------------
- # * Aliasing methods
- #-----------------------------------------------------------------------------
- alias :darksky_spriteset_map_abs_update :update
- alias :darksky_spriteset_map_abs_init :initialize
- #-----------------------------------------------------------------------------
- # * Initialize
- #-----------------------------------------------------------------------------
- def initialize
- darksky_spriteset_map_abs_init()
- create_player_shadow
- @curr_y = $game_player.screen_y
- end
- #-----------------------------------------------------------------------------
- # * Create Shadow
- #-----------------------------------------------------------------------------
- def create_player_shadow
- @p_shadow = Sprite.new()
- @p_shadow.bitmap = Cache.system("Shadow")
- @p_shadow.visible = false
- @p_shadow.ox += 16
- @p_shadow.oy += 10
- end
- #-----------------------------------------------------------------------------
- # * Update Shadow
- #-----------------------------------------------------------------------------
- def update_player_jump_shadow
- @p_shadow.visible = $game_player.jumping?
- @p_shadow.x = $game_player.screen_x
- if $game_player.direction == 2 or $game_player.direction == 8
- @p_shadow.y = $game_player.screen_y
- end
- end
- #-----------------------------------------------------------------------------
- # * Check Event Collison
- #-----------------------------------------------------------------------------
- def check_event_collison(x,y,d)
- return false if !$game_player.map_passable?(x,y,d)
- events = $game_map.events.values
- events.each do |event|
- if event.x == x && event.y == y
- return false
- end
- end
- return true
- end
- #-----------------------------------------------------------------------------
- # * Player Jump
- #-----------------------------------------------------------------------------
- def player_jump(xp,yp,d)
- c_x = xp
- c_y = yp
- case d
- when 4,6
- while c_x.abs > 0
- if $game_player.map_passable?($game_player.x+c_x,$game_player.y+c_y,d) && check_event_collison($game_player.x+c_x,$game_player.y+c_y,d)
- j_se = RPG::SE.new("Jump1")
- j_se.play
- @p_shadow.y = $game_player.screen_y
- $game_player.jump(c_x,c_y)
- c_x = 0
- return
- else
- c_x -= 1 if xp > 0
- c_x += 1 if xp < 0
- end
- end
- when 2,8
- while c_y.abs > 0
- if $game_player.map_passable?($game_player.x+c_x,$game_player.y+c_y,d) && check_event_collison($game_player.x+c_x,$game_player.y+c_y,d)
- j_se = RPG::SE.new("Jump1")
- j_se.play
- $game_player.jump(c_x,c_y)
- c_y = 0
- return
- else
- c_y -= 1 if yp > 0
- c_y += 1 if yp < 0
- end
- end
- end
- j_se = RPG::SE.new("Jump1")
- j_se.play
- $game_player.jump(0,0)
- end
- #-----------------------------------------------------------------------------
- # * Update
- #-----------------------------------------------------------------------------
- def update
- darksky_spriteset_map_abs_update()
- update_player_jump_shadow if @p_shadow
- if $game_player.dash? && $game_player.moving?
- @jump_speed = DASH_JUMP_DISTANNCE
- else
- @jump_speed = NORMAL_JUMP_DISTANNCE
- end
- if Input.trigger?(JUMP_KEY) && !$game_player.jumping?
- case $game_player.direction
- when 2
- player_jump(0,@jump_speed,$game_player.direction)
- when 4
- player_jump(-@jump_speed,0,$game_player.direction)
- when 6
- player_jump(@jump_speed,0,$game_player.direction)
- when 8
- player_jump(0,-@jump_speed,$game_player.direction)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment