TheoAllen

VX Passability Debug

Oct 27th, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.28 KB | None | 0 0
  1. class Plane_Mask < Plane
  2.   ColorPass   = Color.new(255,255,255,125)
  3.   ColorImpass = Color.new(0,0,0,125)
  4.  
  5.   def initialize(vport)
  6.     super(vport)
  7.     @width = 1
  8.     @height = 1
  9.     self.z = 90
  10.   end
  11.  
  12.   def update
  13.     if $game_map
  14.       if @width != $game_map.width || @height != $game_map.height
  15.         @width = $game_map.width
  16.         @height = $game_map.height
  17.         update_bitmap
  18.       end
  19.       self.ox = $game_map.display_x / 8
  20.       self.oy = $game_map.display_y / 8
  21.     end
  22.   end
  23.  
  24.   def update_bitmap
  25.     bmp = Bitmap.new(@width * 32, @height * 32)
  26.     @width.times do |xp|
  27.       @height.times do |yp|
  28.         rect = [xp * 32 + 4, yp * 32 + 4, 32 - 8, 32 - 8]
  29.         if $game_player.map_passable?(xp, yp)
  30.           rect << ColorPass
  31.           bmp.fill_rect(*rect)
  32.         else
  33.           rect << ColorImpass
  34.           bmp.fill_rect(*rect)
  35.         end
  36.       end
  37.     end
  38.     self.bitmap = bmp
  39.   end
  40.  
  41. end
  42.  
  43. class Spriteset_Map
  44.  
  45.   alias theo_init initialize
  46.   def initialize
  47.     theo_init
  48.     @mask = Plane_Mask.new(@viewport1)
  49.     @mask.update
  50.   end
  51.  
  52.   alias theo_update update
  53.   def update
  54.     theo_update
  55.     @mask.update if @mask
  56.   end
  57.  
  58.   alias theo_dispose dispose
  59.   def dispose
  60.     theo_dispose
  61.     @mask.dispose
  62.   end
  63.  
  64. end
Advertisement
Add Comment
Please, Sign In to add comment