Don't forget to credit RPG Advocate and Guillaume777. Although I think it could have been done with less code... Instructions are inside.
#==============================================================================
# Autoscroll script
#------------------------------------------------------------------------------
# Script by RPG Advocate, modified by Guillaume777
# 1
# 2005/12/25
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# Adds accessor for $game_system.autoscroll_x_speed and autoscroll_y_speed
#--------------------------------------------------------------------------
attr_accessor :autoscroll_x_speed
attr_accessor :autoscroll_y_speed
end
class Spriteset_Map
#--------------------------------------------------------------------------
# * Change the panorama x-y for new autoscroll values
#--------------------------------------------------------------------------
alias g7_as_spriteset_map_update update
def update
g7_as_spriteset_map_update # do the normal update
if @panorama.bitmap == nil then return end # if no panorama then do nothing
# if custom autoscroll values are set
if self.autoscroll_x_speed != 0 or self.autoscroll_y_speed != 0
self.scroll #get new scroll_point values
@panorama.ox = self.scroll_point_x
@panorama.oy = self.scroll_point_y
end
end
#--------------------------------------------------------------------------
# Set scroll point x and scroll point y to reflect autoscrolling
#--------------------------------------------------------------------------
def scroll
w = @panorama.bitmap.width
h = @panorama.bitmap.height
self.scroll_frames_x += self.autoscroll_x_speed
self.scroll_frames_y += self.autoscroll_y_speed
while self.scroll_frames_x >= 8
self.scroll_frames_x -= 8
self.scroll_point_x += 1
end
while self.scroll_frames_x <= -8
self.scroll_frames_x += 8
self.scroll_point_x -= 1
end
while self.scroll_frames_y >= 8
self.scroll_frames_y -= 8
self.scroll_point_y += 1
end
while self.scroll_frames_y <= -8
self.scroll_frames_y += 8
self.scroll_point_y -= 1
end
self.scroll_point_x -= w if self.scroll_point_x > w
self.scroll_point_x += w if self.scroll_point_x < -w
self.scroll_point_y -= h if self.scroll_point_y > h
self.scroll_point_y += h if self.scroll_point_y < -h
end
#--------------------------------------------------------------------------
# Returns $game_system.autoscroll_x_speed or 0 if it is nil
#--------------------------------------------------------------------------
def autoscroll_x_speed
return $game_system.autoscroll_x_speed != nil ? $game_system.autoscroll_x_speed : 0
end
#--------------------------------------------------------------------------
# Returns $game_system.autoscroll_y_speed or 0 if it is nil
#--------------------------------------------------------------------------
def autoscroll_y_speed
return $game_system.autoscroll_y_speed != nil ? $game_system.autoscroll_y_speed : 0
end
#--------------------------------------------------------------------------
# Returns @scroll_frames_x or 0 if it is nil
#--------------------------------------------------------------------------
def scroll_frames_x
return @scroll_frames_x != nil ? @scroll_frames_x : 0
end
#--------------------------------------------------------------------------
# Set new @scroll_frames_x
#--------------------------------------------------------------------------
def scroll_frames_x=(value)
@scroll_frames_x = value
end
#--------------------------------------------------------------------------
# Returns @scroll_frames_y or 0 if it is nil
#--------------------------------------------------------------------------
def scroll_frames_y
return @scroll_frames_y != nil ? @scroll_frames_y : 0
end
#--------------------------------------------------------------------------
# Set new @scroll_frames_y
#--------------------------------------------------------------------------
def scroll_frames_y=(value)
@scroll_frames_y = value
end
#--------------------------------------------------------------------------
# Returns @scroll_point_x or 0 if it is nil
#--------------------------------------------------------------------------
def scroll_point_x
return @scroll_point_x != nil ? @scroll_point_x : 0
end
#--------------------------------------------------------------------------
# Set new @scroll_point_x
#--------------------------------------------------------------------------
def scroll_point_x=(value)
@scroll_point_x = value
end
#--------------------------------------------------------------------------
# Returns @scroll_point_y or 0 if it is nil
#--------------------------------------------------------------------------
def scroll_point_y
return @scroll_point_y != nil ? @scroll_point_y : 0
end
#--------------------------------------------------------------------------
# Set new @scroll_point_y
#--------------------------------------------------------------------------
def scroll_point_y=(value)
@scroll_point_y = value
end
end