Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Simple Seamless Map Transition Script (RMXP), Make you world feel more connected.
Rimrook
post Dec 23 2011, 08:38 AM
Post #1


Level 2
Group Icon

Group: Member
Posts: 25
Type: Developer
RM Skill: Advanced




This script was written for me, however, it seems to conflict with a few things in my project and I haven't been using it, so I'm posting it.

In a nutshell, the script takes and old map and slides it off in a direction, and slides the new map next to it, giving a seamless pan like that you see in Zelda Link to the Past, Metroid when you enter doors, and so on. It's handy.

Script
CODE
#==============================================================================
# ** Night_Runner's Map Sliding
#------------------------------------------------------------------------------
# History:
#  Date Created: 15/Dec/10
#  Created for: Rimrook
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=46950
#
# Description:
#  This script allows the designer to seamlessly slide between maps
#
# How to Install:
#  Meh.
#
# How to Use:
#  Line 97 defines the speed at which the maps slide
#  To call this, have an event run the code:
#      $game_temp.transition_slide = 2
#   where 2 is the direction of the new map (see your numpad), and then
#   run a transfer player as normal.
#==============================================================================



#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  Edited to keep a flag if the sliding transition needs to keep the spritemap,
#  and has a integer to track the direction of the sliding map.
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_transmap_initialize  initialize  unless $@
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :keep_map
  attr_accessor :transition_slide
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  # alias nr_transmap_initialize  initialize  unless $@
  def initialize(*args)
    @keep_map = false
    @transition_slide = false
    return nr_transmap_initialize(*args)
  end
end



#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  Edited to allow movement of the viewports rectangles, and to not
#  dispose the map if the sliding transition needs it.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_transmap_dispose  dispose  unless $@
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  # alias nr_transmap_dispose  dispose  unless $@
  def dispose(*args)
    return if $game_temp.keep_map
    return nr_transmap_dispose(*args)
  end
  #--------------------------------------------------------------------------
  # * Rect=(Dimensions)
  #--------------------------------------------------------------------------
  def rect=(*args)
    @viewport1.rect = *args
    @viewport2.rect = *args
    @viewport3.rect = *args
  end
end



#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Edited to keep the old and new map, and slide between them.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Constant
  #--------------------------------------------------------------------------
  SPEED = 30
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_transmap_transfer_player  transfer_player  unless $@
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player(*args)
    # If sliding
    if [2, 4, 6, 8].include?($game_temp.transition_slide)
      # Backup the current spriteset
      old_spriteset = @spriteset.dup
      # Cancel disposing the spriteset
      $game_temp.keep_map = true
      # Don't transition into the new, map, we're going to slide.
      $game_temp.transition_processing = false
      # Run original transfer_player
      nr_transmap_transfer_player(*args)
      # Do the main processing
      case $game_temp.transition_slide
      when 2 # Slide new map up
        # Reposition the spriteset
        @spriteset.rect = Rect.new(0, 640, 640, 480)
        # Transition over
        Graphics.transition(0)
        # Slide the spritesets
        for i in 0..480 / SPEED
          old_spriteset.rect = Rect.new(0, -i * SPEED, 640, 480)
          @spriteset.rect = Rect.new(0, 480 - i * SPEED, 640, 480)
          Graphics.update
        end
      when 4 # Slide new map right
        # Reposition the spriteset
        @spriteset.rect = Rect.new(-640, 0, 640, 480)
        # Transition over
        Graphics.transition(0)
        # Slide the spritesets
        for i in 0..640 / SPEED
          old_spriteset.rect = Rect.new(i * SPEED, 0, 640, 480)
          @spriteset.rect = Rect.new(-640 + i * SPEED, 0, 640, 480)
          Graphics.update
        end
      when 6 # Slide new map left
        # Reposition the spriteset
        @spriteset.rect = Rect.new(640, 0, 640, 480)
        # Transition over
        Graphics.transition(0)
        # Slide the spritesets
        for i in 0..640 / SPEED
          old_spriteset.rect = Rect.new(-i * SPEED, 0, 640, 480)
          @spriteset.rect = Rect.new(640 - i * SPEED, 0, 640, 480)
          Graphics.update
        end
      when 8 # Slide new map down
        # Reposition the spriteset
        @spriteset.rect = Rect.new(0, -480, 640, 480)
        # Transition over
        Graphics.transition(0)
        # Slide the spritesets
        for i in 0..480 / SPEED
          old_spriteset.rect = Rect.new(0, i * SPEED, 640, 480)
          @spriteset.rect = Rect.new(0, -480 + i * SPEED, 640, 480)
          Graphics.update
        end
      end
      # Force the map to position
      @spriteset.rect = Rect.new(0, 0, 640, 480)
      # Dispose the old spritemap
      $game_temp.keep_map = false
      GC.start
      $game_temp.transition_slide = false
    # If not sliding
    else
      # Run original transfer_player
      return nr_transmap_transfer_player(*args)
    end
  end
end


__________________________
Currently working on: "PX"
■□□□□□□□□□ Maps
■□□□□□□□□□ Characters
■■□□□□□□□□ Graphics
■■■■■■■■■□ Music
■■□□□□□□□□ Sound
■■■■■■■■■■ Story
■■■■■■■■■□ Systems
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 03:59 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker