First thing you need to do is make it possible to reach the movement speed of the player. By default there is no access to it outside of the class. So lets make an
attr_accessor for the
Game_Player's
@move_speed. After that we will need to find the Scene where we would want the player to run around in. That scene is
Scene_Map. We want to test for input as much as we can and to do that we will need to add to the
update method of
Scene_Map. We will then alias this method so we don't destroy all the old code like updating the map and receiving all the other input. After we
alias_method the
update method we can add our code to it. We want to be testing for the key being held down which is
Input.press? and the key I will be checking for is
Input::C. While the key is held down I want the speed to increase otherwise I want the speed value to go back to the default value which is 4.
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================
class Game_Player
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :move_speed
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
Run_Speed = 5
Run_Key = Input::C
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :line_running_scene_map_update, :update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
$game_player.move_speed = Input.press?(Run_Key) ? Run_Speed : 4
line_running_scene_map_update
end
end
Just insert an empty section above main and post in that code. The key to run is C by default but its a constant in the Scene_Map declaration so feel free to change it. Run_Speed as well can be adjusted to whatever you like.
Good luck with it Lost_in_Exsistance! :thumb: