R=4 # размер квадрата
DX=25*R+12 # ширина
DY=20*R+12 # высота
X_POS=640-DX # позиция по х
Y_POS=480-DY # позиция по у
X=1
Y=2
class Scene_Map
  
  alias scene_map_main main
  alias scene_map_update update
    
  def main
    # рисуем окно
    @stats_window = Window_Mini_map.new 
    @stats_window.opacity = 75
    @stats_window.x = X_POS
    @stats_window.y = Y_POS
    #-------------------------------------------------
    scene_map_main      # Вызываем настоящию Scene_Map
    @stats_window.dispose
  end
  
  def update
    @stats_window.update
    scene_map_update    # call REAL Scene_Map update
  end
  
end
class Window_Mini_map < Window_Base
  def initialize
    super(0, 0, DX, DY)
    self.contents = Bitmap.new(20*R, 15*R)
    @counter = 20
    self.x=0
    self.y=0
    refresh
  end
  
  def refresh
    self.contents.clear
    @x=$game_variables[X] # Х поз
    @y=$game_variables[Y] # У поз 
    @map=$game_map # мапа
    @tid=@map.tileset_name.to_i # Ид тайлсета (имя файла)\\ доработать##(имя тайла должно содержать номер тайлсета)
    self.contents.fill_rect(0,0,20*R,20*R, Color.new(250,250,250,200))
    mini_map 
   self.contents.fill_rect(@x*R-@x1*R,@y*R-@y1*R,R,R, Color.new(255,0,0,200))
  end
  
#------------------------------------------------------------------------
def mini_map 
#------------------------------------------------------------------------
#------------------------------------------------------------------------
@x1=0
@x2=19
@y1=0
@y2=14
#------------------------------------------------------------------------
#------------------------------------------------------------------------
if @map.width>20 
  if @x>=10
    then 
     @x1=@x-10 
     @x2=@x+9 
   else 
     @x1=0 
     @x2=19
  end
end   
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if @map.height>15
  if @y>=7 
    then 
     @y1=@y-7
     @y2=@y+7
   else
     @y1=0
     @y2=14
  end   
end
#------------------------------------------------------------------------
#------------------------------------------------------------------------
  for i in @x1..@x2
    for j in @y1..@y2
       mini_map_ini(i,j)
    end
  end 
#------------------------------------------------------------------------
#------------------------------------------------------------------------
end  
#------------------------------------------------------------------------
#------------------------------------------------------------------------
def mini_map_ini(i,j)
begin p0=$data_tilesets[@tid].passages[@map.data[i,j,0]] rescue p0=666 end    # проходимость слоя 1
begin p1=$data_tilesets[@tid].passages[@map.data[i,j,1]] rescue p1=666 end  # проходимость слоя 2
begin p2=$data_tilesets[@tid].passages[@map.data[i,j,2]] rescue p0=666 end  # проходимость слоя 3 
 mini_map_paint(p0,p1,p2,i,j) 
end  
#-------------------------------
# рисуем ректы мапы (доработать)
#-------------------------------
def paint(i,j,r=0,g=0,b=0,a=200)
  self.contents.fill_rect(i*R-@x1*R,j*R-@y1*R,R,R, Color.new(r,g,b,a))
end  
def case_p(p,i,j)
  case p
   when 0  
   when 666 
     paint(i,j,0,0,0)
  when 143  
    paint(i,j,150,0,150)  
   when 64
    paint(i,j,150,150,150) 
  else 
    if p>=1 and p<15 then paint(i,j,125,125,125) else  paint(i,j,0,0,0) end
  end
end  
def mini_map_paint(p0,p1,p2,i,j)
  case_p(p0,i,j)
  case_p(p1,i,j)
  case_p(p2,i,j)
end  
#-------------------------------
# обновляем через @counter кадров, малое значение вызывает лаги, наверно...
#-------------------------------
  def update
    super
    @counter -= 1
    if @counter == 0 
      refresh
      @counter = 10
    end
  end
end
 
Социальные закладки