Options

# Diagonal Map Scrolling

• #### Index

• Diagonal Map Scrolling
• This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
```#---------------------------------------------------------------------------- #Diagonal scrolling tool by Khatharr. #To use, simply invoke \$game_map.start_diag(x, y, speed). #X and Y are in map tiles. #Note that speed can be any integer number. #A speed of 1 is very slow and a speed of 6 is pretty fast, #so you may wish to tinker with it if you like.  Integers only, though. #http://www.dubealex.com #---------------------------------------------------------------------------- class Game_Map   #----------------------------------------------------------------------------   alias k_dscroller_init initialize   alias k_dscroller_upd update   #----------------------------------------------------------------------------   def initialize     k_dscroller_init     @diag_rest = 0   end   #----------------------------------------------------------------------------   def update     if @diag_rest > 0       @diag_rest -= 1       ary = @line[@diag_rest]       @display_x = ary[0]       @display_y = ary[1]       k_dscroller_upd     end   end   #----------------------------------------------------------------------------   def start_diag(x, y, speed)     speed *= 2     x = (x - 9.5) * 128     y = (y - 7) * 128     xlen = @display_x - x     ylen = @display_y - y     len = Math.hypot(xlen, ylen)     @line = []     @line.push([@display_x, @display_y])     for i in 1..len       @line.push([(@display_x - ((xlen / len) * i)).to_i, (@display_y - ((ylen / len) * i)).to_i])     end     for i in 1..speed       for a in 0...@line.size         if a % 2 == 0           @line.delete_at(a)         end       end     end     @line.push([x, y])     @diag_rest = @line.size     @line.reverse!   end   #----------------------------------------------------------------------------   def scrolling?     return true if @scroll_rest > 0     return true if @diag_rest > 0     return false   end   #---------------------------------------------------------------------------- end #---------------------------End of script---------------------------```