Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #------------------------------------------------------------------------------
- # * License :
- #
- # Copyright (C) 2015 Zeriab
- #
- # This software is provided 'as-is', without any express or implied warranty.
- # In no event will the authors be held liable for any damages arising from
- # the use of this software.
- # Permission is granted to anyone to use this software for any purpose,
- # including commercial applications, and to alter it and redistribute it
- # freely, subject to the following restrictions:
- #
- # 1. The origin of this software must not be misrepresented; you must not
- # claim that you wrote the original software. If you use this software
- # in a product, an acknowledgment in the product documentation would
- # be appreciated but is not required.
- # 2. Altered source versions must be plainly marked as such, and must not
- # be misrepresented as being the original software.
- # 3. This notice may not be removed or altered from any source distribution.
- #
- def float_event_to(event_id, x, y)
- event = $game_map.events[event_id]
- event.float_to(x, y)
- end
- def float_event(event_id, x, y)
- event = $game_map.events[event_id]
- absolut_x = event.x + x
- absolut_y = event.y + y
- event.float_to(absolut_x, absolut_y)
- end
- class Game_Event < Game_Character
- def float_to(x, y)
- @x_dist = (x - @x).abs.to_f
- @y_dist = (y - @y).abs.to_f
- @x = x % $game_map.width
- @y = y % $game_map.height
- @floating = true
- end
- ##
- # Update While Moving
- #
- def update_move
- distance = distance_per_frame
- # During float the distance travelled may be different between the axis
- if @floating && (@x_dist + @y_dist > 0)
- @x_dist ||= 1
- @y_dist ||= 1
- total_distance = @x_dist + @y_dist
- x_distance = ((distance * @x_dist) / total_distance)
- y_distance = ((distance * @y_dist) / total_distance)
- else
- x_distance = distance
- y_distance = distance
- end
- # Coordinate dependent distance
- @real_x = [@real_x - x_distance, @x].max if @x < @real_x
- @real_x = [@real_x + x_distance, @x].min if @x > @real_x
- @real_y = [@real_y - y_distance, @y].max if @y < @real_y
- @real_y = [@real_y + y_distance, @y].min if @y > @real_y
- update_bush_depth unless moving?
- # Remove float status
- if @floating && !moving?
- @floating = false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement