All pastes #200241 Raw Edit

Unnamed

public ruby v1 · immutable
#200241 ·published 2006-10-13 01:28 UTC
rendered paste body
class Scene_Title  $map_names = load_data("Data/MapInfos.rxdata")  for key in $map_names.keys    $map_names[key] = $map_names[key].name  end  alias prexus_metroid_stitle_command_new_game command_new_game  def command_new_game    $map_objects = {}    for key in $map_names.keys      map_info = $map_names[key].split('-')      $map_objects[key] = Map_Object.new      $map_objects[key].big_id = map_info[0]      $map_objects[key].x = alpha_convert(map_info[1])      $map_objects[key].y = map_info[2].to_i - 1      $map_objects[key].type = type_convert(map_info[3]) if map_info[3]    end    prexus_metroid_stitle_command_new_game  end  def alpha_convert(letter)    case letter.upcase    when 'A'      return 0    when 'B'      return 1    when 'C'      return 2    when 'D'      return 3    when 'E'      return 4    when 'F'      return 5    when 'G'      return 6    when 'H'      return 7    when 'J'      return 8    when 'K'      return 9    end  end  def type_convert(letter)    case letter.upcase    when 'B'      return 1    when 'E'      return 2    end  endendmodule Map_Colors  BORDER = Color.new(255, 255, 255)  UNVISITED = Color.new(96, 96, 96)  VISITED = Color.new(255, 128, 255)  START = Color.new(255, 128, 128)  BOSS = Color.new(128, 128, 255)endclass Map_Object  attr_accessor :big_id  attr_accessor :x  attr_accessor :y  attr_accessor :visited  attr_accessor :type  def initialize    @big_id = 0    @x = 0    @y = 0    @visited = false    @type = 0 # 0 = Blank, 1 = Dungeon Entrance, 2 = Boss Area  endendclass Game_Map  alias prexus_metroid_gmap_setup setup  def setup(map_id)    prexus_metroid_gmap_setup(map_id)    unless $map_objects[@map_id].visited      $map_objects[@map_id].visited = true    end    if $scene.is_a?(Scene_Map)      if $scene.map.big_id != $map_objects[@map_id].big_id        $scene.map.big_id = $map_objects[@map_id].big_id      end      $scene.map.refresh    end  end  def big_id    return $map_objects[@map_id].big_id  endendclass Map < Sprite  attr_accessor :big_id  def initialize    super()    self.x, self.y = 0, 0    self.bitmap = Bitmap.new(640, 480)    self.bitmap.font.name = 'Georgia'    self.bitmap.font.bold = true    self.bitmap.font.size = 14    self.opacity = 255    self.visible = true    @offset = [32, 32] # [x, y]    @room_size = [24, 16] # [width, height]    @big_id = 0    refresh  end  def refresh    self.bitmap.clear    return unless @big_id != 0    maps = {}    for object in $map_objects      next unless object[1].big_id == @big_id      maps[object[0]] = object[1]    end    top_x = 0    top_y = 0    for map in maps.values      top_x = map.x if top_x < map.x      top_y = map.y if top_y < map.y    end    for x in 0..top_x + 1      for y in 0..top_y + 1        map = find_map(maps, x, y)        next unless map        draw_x = @offset[0] + (x * @room_size[0])        draw_y = @offset[1] + (y * @room_size[1])        self.bitmap.fill_rect(draw_x, draw_y, @room_size[0], @room_size[1],                              Map_Colors::BORDER)        fill_color = (map.visited ? Map_Colors::VISITED : Map_Colors::UNVISITED)        self.bitmap.fill_rect(draw_x + 1, draw_y + 1, @room_size[0] - 2,                              @room_size[1] - 2, fill_color)        case map.type        when 1          self.bitmap.fill_rect(draw_x + 3, draw_y + 3, @room_size[0] - 6,                                @room_size[1] - 6, Map_Colors::START)        when 2          self.bitmap.fill_rect(draw_x + 3, draw_y + 3, @room_size[0] - 6,                                @room_size[1] - 6, Map_Colors::BOSS)        end      end    end  end  def find_map(hash, x, y)    for map in hash.values      return map if (map.x == x) and (map.y == y)    end    return nil  end  def update    if @big_id != $game_map.big_id      @big_id = $game_map.big_id      refresh    end  endendclass Scene_Map  attr_accessor :map  alias prexus_metroid_smap_main main  def main    @map = Map.new    prexus_metroid_smap_main    @map.dispose  end  alias prexus_metroid_smap_update update  def update    @map.update    prexus_metroid_smap_update  endend