RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] Double Tap Dash

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 72
The cloaked schemer
Most Promising Project 2014
Double Tap Dash
Authors: Zexion
Version: 1.0

Introduction

I needed a simple version of a double tap dash system for my game, so I decided to make one as basic as possible. It doesn't handle colliding with objects, or anything fancy like that. Just double tap to activate run, release to stop and walk again.

Features

  • Tap the same direction twice to run
  • Use $game_player.dashing to check if the player is currently dashing. (for events)

Script
Spoiler for:
Code: [Select]
#==============================================================================#
# Author : Zexion / RPGZexion
#------------------------------------------------------------------------------#
# Title : Zexion's Double Tap - Dash
#------------------------------------------------------------------------------#
# Description :
# A simple plug and play double tap to dash system. This does not handle
# collisions with walls. Just double tap a single direction and run freely!
#
# New:
# Can use $game_player.dashing to check if the player is running or not.
#------------------------------------------------------------------------------#
# Compatability :
# Should be 100% compatable with everything. Including blizz ABS.
#------------------------------------------------------------------------------#
# Free to use in any project even commercially.
#------------------------------------------------------------------------------#
class Scene_Map
  alias zex_dtd_main main
  alias zex_dtd_update update
  # Speed config
  DASH_SPEED = 4
  NORM_SPEED = 2
  #-----------------------------------------------------------------------------
  # * main
  #-----------------------------------------------------------------------------
  # Initializes the variables in the main method.
  #-----------------------------------------------------------------------------
  def main
    @dtd_timer = 0
    @direction = 0
    @tapped = false
    @dash = false
    zex_dtd_main
  end
  #-----------------------------------------------------------------------------
  # * update
  #-----------------------------------------------------------------------------
  # Frame update.
  #-----------------------------------------------------------------------------
  def update
    zex_dtd_update
    double_tap_update
  end
  #-----------------------------------------------------------------------------
  # * double_tap_update
  #-----------------------------------------------------------------------------
  # Handles the double tap system.
  #-----------------------------------------------------------------------------
  def double_tap_update
    # Check if any direction is being pressed
    if Input.press?(Input::UP) or Input.press?(Input::DOWN) or
      Input.press?(Input::LEFT) or Input.press?(Input::RIGHT)
      # Check if the button is 'tapped'
      if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
        Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
        # If it was tapped for the first time
        if !@tapped
          @dtd_timer = 30
          @tapped = true
          @direction = Input.dir8
        else
          # Dash if not the first tap && tapping same key.
          if @direction == Input.dir8
            @dash = true
          else
            # If the key is not the same, reset
            @tapped = false
            @dtd_timer = 0
            @direction = 0
            @dash = false
          end
        end
      end
    else
      # Set dash to false
      @dash = false if @dash && @dtd_timer == 0
    end
    # Decrement timer if needed
    @dtd_timer -= 1 if @dtd_timer > 0
    # Reset tapped state if time is run out
    @tapped = false if @tapped && @dtd_timer == 0
    # Change character speed as needed
    if !$BlizzABS
      $game_player.move_speed = DASH_SPEED if @dash && $game_player.move_speed != 4
      $game_player.move_speed = NORM_SPEED if !@dash && $game_player.move_speed != 3
    else
      $game_player.normal_speed = DASH_SPEED if @dash && $game_player.move_speed != 4
      $game_player.normal_speed = NORM_SPEED if !@dash && $game_player.move_speed != 3
    end
    $game_player.dashing = @dash if $game_player.dashing != @dash
  end
end
#------------------------------------------------------------------------------#
# * Game_Player
#------------------------------------------------------------------------------#
class Game_Player
  # Makes move_speed modifyable outside the class.
  attr_accessor :move_speed
  # NEW - Added a state to check if the player is dashing
  attr_accessor :dashing
  alias zex_gp_dtr_init initialize
  def initialize
    @dashing = false
    zex_gp_dtr_init
  end
end

Instructions

Plug and play.

Compatibility

Should be compatible with anything. Even blizz abs.

****
Rep:
Level 43
Somewhat got a project? (\รด/)
GIAW 14: ParticipantParticipant - GIAW 11
You readed my mind, right?
Yesterday, I thought how cool a run function is in XP and now you made one. O.o
This is script is awesome and easy to configure. Thank you, you did awesome work. :) (\s/)