Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Jump Script

Hey, I have a jump script, but I wanted two thing done to it, first of all, when you are on the edge of the screen and the press the button, it double jumps :S also, I wanted to know if there was a way of stopping the player from continualy holding down the button so all it does is jump, so something like a waiting time before you can do it again? Here's the scipt...

Code:
#==============================================================================
# â–  Jump Script
#------------------------------------------------------------------------------
# Enables jumping around the map
# Made by: Huitzilopoctli @ rmxp.net
#------------------------------------------------------------------------------
# Press the A Input (ShiftKey) to jump
# The player will be able to jump over any passable tile, or any tile with a
# TerrainID the same as the JumpID
# The player must land on a passable tile without a solid event blocking it
# If the player can't jump the full 2 tiles, it will go 1 or, failing that, none
# To stop the player from jumping over a particular event, make the first
# command for the event a comment, containing this word: \Tall
# To create a 'tall' tile that will stop the player from jumping over it even if
# the tile below is jumpable, set the tile's id to not the JumpID or 0
#==============================================================================

#==============================================================================
# ● Customisation
#==============================================================================

JumpID = 1 # The terrain ID of the tiles which can be jumped over

#==============================================================================
# ● Game_Player
#==============================================================================

class Game_Player < Game_Character

def leap
xdir = (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
ydir = (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)

dist = 0

clear_jump = true
clear_land1 = true
e = $game_map.events[$game_map.check_event(@x + xdir, @y + ydir)]
if e
clear_jump = !(e.list[0].code == 108 && e.list[0].parameters[0] =~ "\Tall")
clear_land1 = e.through
end

clear_land2 = true
e = $game_map.events[$game_map.check_event(@x + xdir * 2, @y + ydir * 2)]
if e
clear_land2 = e.through
end

pass1 = $game_map.passable?(@x + xdir, @y + ydir, @direction)
pass2 = $game_map.passable?(@x + xdir * 2, @y + ydir * 2, @direction)

jumpid = $game_map.terrain_tag(@x + xdir, @y + ydir) == JumpID

dist = 0
if clear_jump
if clear_land2 & pass2 & (jumpid | pass1)
dist = 2
elsif clear_land1 & pass1
dist = 1
end
end

route = RPG::MoveRoute.new
route.list.clear
route.list.push(RPG::MoveCommand.new(37))
route.list.push(RPG::MoveCommand.new(14, [xdir * dist, ydir * dist]))
route.list.push(RPG::MoveCommand.new(38))
route.list.push(RPG::MoveCommand.new(0))
route.repeat = false
$route = route

$game_player.force_move_route(route)
end

alias update_primary update
def update
update_primary

leap if $game_switches[3] and Input.press?(Input::SHIFT) && !moving?
end

end

Thank You :D
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top