У меня большая система передвижения персонажа, наподобие ABS.
Там есть Game_Player. Вот весь кусок скрипта.
Код:#============================================================================== # * Game_Player #------------------------------------------------------------------------------ # It is the class which handles the prayer. It has the function of starting decision of the # event and the scroll etc. of the map. Instance of this class is referred to being $game_player. #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # - Constant #-------------------------------------------------------------------------- CENTER_X = (320 - 16) * 4 # Picture central X coordinate * 4 CENTER_Y = (240 - 16) * 4 # Picture central Y coordinate * 4 #------------------------------------------------------------------------ # * Check for character diagonal image existence #------------------------------------------------------------------------ def img_dia_exist?(actor) begin RPG::Cache.character(actor.character_name.to_s + "_quarter", actor.character_hue) rescue return false end return true end #------------------------------------------------------------------------ # * Check for character dash image existence #------------------------------------------------------------------------ def img_exist?(actor) begin RPG::Cache.character(actor.character_name.to_s + "_dash", actor.character_hue) rescue return false end return true end #-------------------------------------------------------------------------- # - Frame renewal #-------------------------------------------------------------------------- def update # Whether or not in local variable on the move you remember last_moving = moving? # On the move, during event executing and during movement route forcing # When it is not in each case is in the midst of message window indicating # The A when button is pushed # Acquiring the first actor unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # If the direction button is pushed, moving the prayer to that direction if $game_party.actors[0] != nil actor = $game_party.actors[0] if Input.press?(Input::R) then @move_speed=5 else @move_speed=3 end #weapon set if Input.press?(Input::A) and actor.weapon_id != 0 $game_temp.act = true @character_name = actor.character_name + "_" + $data_weapons[actor.weapon_id].name elsif Input.press?(Input::Y) $game_temp.act = true @character_name = actor.character_name + "_dash" + $data_weapons[actor.weapon_id].name else $game_temp.act = false # Setting the file name and hue of the character @character_name = actor.character_name end end if $game_temp.act case Input.dir8 when 9 move_right move_up if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end when 8 move_up when 7 move_up move_left if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end when 6 move_right when 4 move_left when 3 move_down move_right if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end when 2 move_down when 1 move_left move_down if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end end else case Input.dir8 when 9 move_right move_up if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end when 8 move_up when 7 move_up move_left if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end when 6 move_right when 4 move_left when 3 move_down move_right if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end when 2 move_down when 1 move_left move_down if img_dia_exist?(actor) @character_name = actor.character_name + "_quarter" end end end end # Remembering coordinate in local variable last_real_x = @real_x last_real_y = @real_y super # The character moves under, at the same time when position on the picture it is under from the center if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # Map under scroll $game_map.scroll_down(@real_y - last_real_y) end # The character moves to the left, at the same time when position on the picture it is the left from the center if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # Map on the left scroll $game_map.scroll_left(last_real_x - @real_x) end # The character moves to the right, at the same time when position on the picture it is the right from the center if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # Map on the right scroll $game_map.scroll_right(@real_x - last_real_x) end # The character moves on, at the same time when position on the picture it is on from the center if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # Map on scroll $game_map.scroll_up(last_real_y - @real_y) end # When it is not on the move unless moving? # When the previous prayer is on the move if last_moving # The event starting decision with the contact with the event of the same position result = check_event_trigger_here([1,2]) # When there is no event which it starts if result == false # Debugging mode excluding the case where ON and the CTRL key are pushed unless $DEBUG and Input.press?(Input::CTRL) # Encounter countdown if @encounter_count > 0 @encounter_count -= 1 end end end end # When C button is pushed if Input.trigger?(Input::C) and $game_temp.act != true # The same position and event starting decision of front check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end

Хорошо!:
Плохо!:

Ответить с цитированием





Социальные закладки