Class: Game_Map
- Inherits:
-
Object
- Object
- Game_Map
- Defined in:
- lib/rgss3_default_scripts/Game_Map.rb
Overview
** Game_Map
This class handles maps. It includes scrolling and passage determination
functions. The instance of this class is referenced by $game_map.
Instance Attribute Summary collapse
-
#battleback1_name ⇒ Object
readonly
battle background (floor) filename.
-
#battleback2_name ⇒ Object
readonly
battle background (wall) filename.
-
#display_x ⇒ Object
readonly
display X coordinate.
-
#display_y ⇒ Object
readonly
display Y coordinate.
-
#events ⇒ Object
readonly
events.
-
#interpreter ⇒ Object
readonly
map event interpreter.
-
#name_display ⇒ Object
map name display flag.
-
#need_refresh ⇒ Object
refresh request flag.
-
#parallax_name ⇒ Object
readonly
parallax background filename.
-
#screen ⇒ Object
readonly
————————————————————————– * Public Instance Variables ————————————————————————–.
-
#vehicles ⇒ Object
readonly
vehicle.
Instance Method Summary collapse
-
#adjust_x(x) ⇒ Object
————————————————————————– * Calculate X Coordinate, Minus Display Coordinate ————————————————————————–.
-
#adjust_y(y) ⇒ Object
————————————————————————– * Calculate Y Coordinate, Minus Display Coordinate ————————————————————————–.
-
#airship ⇒ Object
————————————————————————– * Get Airship ————————————————————————–.
-
#airship_land_ok?(x, y) ⇒ Boolean
————————————————————————– * Determine if Airship can Land ————————————————————————–.
-
#all_tiles(x, y) ⇒ Object
————————————————————————– * Get Array of All Tiles (Including Events) at Specified Coordinates ————————————————————————–.
-
#any_event_starting? ⇒ Boolean
————————————————————————– * Determine Existence of Starting Map Event ————————————————————————–.
-
#autoplay ⇒ Object
————————————————————————– * Automatically Switch BGM and BGS ————————————————————————–.
-
#autotile_type(x, y, z) ⇒ Object
————————————————————————– * Get Type of Auto Tile at Specified Coordinates ————————————————————————–.
-
#boat ⇒ Object
————————————————————————– * Get Boat ————————————————————————–.
-
#boat_passable?(x, y) ⇒ Boolean
————————————————————————– * Determine if Passable by Boat ————————————————————————–.
-
#bush?(x, y) ⇒ Boolean
————————————————————————– * Determine if Bush ————————————————————————–.
-
#change_battleback(battleback1_name, battleback2_name) ⇒ Object
————————————————————————– * Change Battle Background ————————————————————————–.
-
#change_parallax(name, loop_x, loop_y, sx, sy) ⇒ Object
————————————————————————– * Change Parallax Background ————————————————————————–.
-
#change_tileset(tileset_id) ⇒ Object
————————————————————————– * Change Tileset ————————————————————————–.
-
#check_passage(x, y, bit) ⇒ Object
————————————————————————– * Check Passage bit: Inhibit passage check bit ————————————————————————–.
-
#counter?(x, y) ⇒ Boolean
————————————————————————– * Determine if Counter ————————————————————————–.
-
#create_vehicles ⇒ Object
————————————————————————– * Create Vehicles ————————————————————————–.
-
#damage_floor?(x, y) ⇒ Boolean
————————————————————————– * Determine if Damage Floor ————————————————————————–.
-
#data ⇒ Object
————————————————————————– * Get Map Data ————————————————————————–.
-
#disable_dash? ⇒ Boolean
————————————————————————– * Get Whether Dash is Disabled ————————————————————————–.
-
#display_name ⇒ Object
————————————————————————– * Get Display Name ————————————————————————–.
-
#do_scroll(direction, distance) ⇒ Object
————————————————————————– * Execute Scroll ————————————————————————–.
-
#encounter_list ⇒ Object
————————————————————————– * Get Encounter List ————————————————————————–.
-
#encounter_step ⇒ Object
————————————————————————– * Get Encounter Steps ————————————————————————–.
-
#event_id_xy(x, y) ⇒ Object
————————————————————————– * Get ID of Events at Designated Coordinates (One Only) ————————————————————————–.
-
#events_xy(x, y) ⇒ Object
————————————————————————– * Get Array of Events at Designated Coordinates ————————————————————————–.
-
#events_xy_nt(x, y) ⇒ Object
————————————————————————– * Get Array of Events at Designated Coordinates (Except Pass-Through) ————————————————————————–.
-
#height ⇒ Object
————————————————————————– * Get Height ————————————————————————–.
-
#initialize ⇒ Game_Map
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#ladder?(x, y) ⇒ Boolean
————————————————————————– * Determine if Ladder ————————————————————————–.
-
#layered_tiles(x, y) ⇒ Object
————————————————————————– * Get Array of All Layer Tiles (Top to Bottom) at Specified Coordinates ————————————————————————–.
-
#layered_tiles_flag?(x, y, bit) ⇒ Boolean
————————————————————————– * Determine Flag for All Layers at Specified Coordinates ————————————————————————–.
-
#loop_horizontal? ⇒ Boolean
————————————————————————– * Loop Horizontally? ————————————————————————–.
-
#loop_vertical? ⇒ Boolean
————————————————————————– * Loop Vertically? ————————————————————————–.
-
#map_id ⇒ Object
————————————————————————– * Get Map ID ————————————————————————–.
-
#overworld? ⇒ Boolean
————————————————————————– * Determine if Field Type ————————————————————————–.
-
#parallax_ox(bitmap) ⇒ Object
————————————————————————– * Calculate X Coordinate of Parallax Display Origin ————————————————————————–.
-
#parallax_oy(bitmap) ⇒ Object
————————————————————————– * Calculate Y Coordinate of Parallax Display Origin ————————————————————————–.
-
#parallel_common_events ⇒ Object
————————————————————————– * Get Array of Parallel Common Events ————————————————————————–.
-
#passable?(x, y, d) ⇒ Boolean
————————————————————————– * Determine Passability of Normal Character d: direction (2,4,6,8) Determines whether the tile at the specified coordinates is passable in the specified direction.
-
#referesh_vehicles ⇒ Object
————————————————————————– * Refresh Vehicles ————————————————————————–.
-
#refresh ⇒ Object
————————————————————————– * Refresh ————————————————————————–.
-
#refresh_tile_events ⇒ Object
————————————————————————– * Refresh Array of Tile-Handling Events ————————————————————————–.
-
#region_id(x, y) ⇒ Object
————————————————————————– * Get Region ID ————————————————————————–.
-
#round_x(x) ⇒ Object
————————————————————————– * Calculate X Coordinate After Loop Adjustment ————————————————————————–.
-
#round_x_with_direction(x, d) ⇒ Object
————————————————————————– * Calculate X Coordinate Shifted One Tile in Specific Direction (With Loop Adjustment) ————————————————————————–.
-
#round_y(y) ⇒ Object
————————————————————————– * Calculate Y Coordinate After Loop Adjustment ————————————————————————–.
-
#round_y_with_direction(y, d) ⇒ Object
————————————————————————– * Calculate Y Coordinate Shifted One Tile in Specific Direction (With Loop Adjustment) ————————————————————————–.
-
#screen_tile_x ⇒ Object
————————————————————————– * Number of Horizontal Tiles on Screen ————————————————————————–.
-
#screen_tile_y ⇒ Object
————————————————————————– * Number of Vertical Tiles on Screen ————————————————————————–.
-
#scroll_distance ⇒ Object
————————————————————————– * Calculate Scroll Distance ————————————————————————–.
-
#scroll_down(distance) ⇒ Object
————————————————————————– * Scroll Down ————————————————————————–.
-
#scroll_left(distance) ⇒ Object
————————————————————————– * Scroll Left ————————————————————————–.
-
#scroll_right(distance) ⇒ Object
————————————————————————– * Scroll Right ————————————————————————–.
-
#scroll_up(distance) ⇒ Object
————————————————————————– * Scroll Up ————————————————————————–.
-
#scrolling? ⇒ Boolean
————————————————————————– * Determine if Scrolling ————————————————————————–.
-
#set_display_pos(x, y) ⇒ Object
————————————————————————– * Set Display Position ————————————————————————–.
-
#setup(map_id) ⇒ Object
————————————————————————– * Setup ————————————————————————–.
-
#setup_autorun_common_event ⇒ Object
————————————————————————– * Detect/Set Up Autorun Common Event ————————————————————————–.
-
#setup_battleback ⇒ Object
————————————————————————– * Set Up Battle Background ————————————————————————–.
-
#setup_events ⇒ Object
————————————————————————– * Event Setup ————————————————————————–.
-
#setup_parallax ⇒ Object
————————————————————————– * Parallax Background Setup ————————————————————————–.
-
#setup_scroll ⇒ Object
————————————————————————– * Scroll Setup ————————————————————————–.
-
#setup_starting_event ⇒ Object
————————————————————————– * Starting Event Setup ————————————————————————–.
-
#setup_starting_map_event ⇒ Object
————————————————————————– * Detect/Set Up Starting Map Event ————————————————————————–.
-
#ship ⇒ Object
————————————————————————– * Get Ship ————————————————————————–.
-
#ship_passable?(x, y) ⇒ Boolean
————————————————————————– * Determine if Passable by Ship ————————————————————————–.
-
#start_scroll(direction, distance, speed) ⇒ Object
————————————————————————– * Start Scroll ————————————————————————–.
-
#terrain_tag(x, y) ⇒ Object
————————————————————————– * Get Terrain Tag ————————————————————————–.
-
#tile_events_xy(x, y) ⇒ Object
————————————————————————– * Get Array of Tile-Handling Events at Designated Coordinates (Except Pass-Through) ————————————————————————–.
-
#tile_id(x, y, z) ⇒ Object
————————————————————————– * Get Tile ID at Specified Coordinates ————————————————————————–.
-
#tileset ⇒ Object
————————————————————————– * Get Tileset ————————————————————————–.
-
#unlock_event(event_id) ⇒ Object
————————————————————————– * Unlock Event ————————————————————————–.
-
#update(main = false) ⇒ Object
————————————————————————– * Frame Update main: Interpreter update flag ————————————————————————–.
-
#update_events ⇒ Object
————————————————————————– * Update Events ————————————————————————–.
-
#update_interpreter ⇒ Object
————————————————————————– * Update Interpreter ————————————————————————–.
-
#update_parallax ⇒ Object
————————————————————————– * Update Parallax ————————————————————————–.
-
#update_scroll ⇒ Object
————————————————————————– * Update Scroll ————————————————————————–.
-
#update_vehicles ⇒ Object
————————————————————————– * Update Vehicles ————————————————————————–.
-
#valid?(x, y) ⇒ Boolean
————————————————————————– * Determine Valid Coordinates ————————————————————————–.
-
#vehicle(type) ⇒ Object
————————————————————————– * Get Vehicle ————————————————————————–.
-
#width ⇒ Object
————————————————————————– * Get Width ————————————————————————–.
-
#x_with_direction(x, d) ⇒ Object
————————————————————————– * Calculate X Coordinate Shifted One Tile in Specific Direction (No Loop Adjustment) ————————————————————————–.
-
#y_with_direction(y, d) ⇒ Object
————————————————————————– * Calculate Y Coordinate Shifted One Tile in Specific Direction (No Loop Adjustment) ————————————————————————–.
Constructor Details
#initialize ⇒ Game_Map
-
Object Initialization
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 26 def initialize @screen = Game_Screen.new @interpreter = Game_Interpreter.new @map_id = 0 @events = {} @display_x = 0 @display_y = 0 create_vehicles @name_display = true end |
Instance Attribute Details
#battleback1_name ⇒ Object (readonly)
battle background (floor) filename
19 20 21 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 19 def battleback1_name @battleback1_name end |
#battleback2_name ⇒ Object (readonly)
battle background (wall) filename
20 21 22 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 20 def battleback2_name @battleback2_name end |
#display_x ⇒ Object (readonly)
display X coordinate
15 16 17 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 15 def display_x @display_x end |
#display_y ⇒ Object (readonly)
display Y coordinate
16 17 18 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 16 def display_y @display_y end |
#events ⇒ Object (readonly)
events
14 15 16 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 14 def events @events end |
#interpreter ⇒ Object (readonly)
map event interpreter
13 14 15 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 13 def interpreter @interpreter end |
#name_display ⇒ Object
map name display flag
21 22 23 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 21 def name_display @name_display end |
#need_refresh ⇒ Object
refresh request flag
22 23 24 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 22 def need_refresh @need_refresh end |
#parallax_name ⇒ Object (readonly)
parallax background filename
17 18 19 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 17 def parallax_name @parallax_name end |
#screen ⇒ Object (readonly)
-
Public Instance Variables
12 13 14 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 12 def screen @screen end |
#vehicles ⇒ Object (readonly)
vehicle
18 19 20 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 18 def vehicles @vehicles end |
Instance Method Details
#adjust_x(x) ⇒ Object
-
Calculate X Coordinate, Minus Display Coordinate
267 268 269 270 271 272 273 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 267 def adjust_x(x) if loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2 x - @display_x + @map.width else x - @display_x end end |
#adjust_y(y) ⇒ Object
-
Calculate Y Coordinate, Minus Display Coordinate
277 278 279 280 281 282 283 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 277 def adjust_y(y) if loop_vertical? && y < @display_y - (height - screen_tile_y) / 2 y - @display_y + @map.height else y - @display_y end end |
#airship ⇒ Object
-
Get Airship
91 92 93 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 91 def airship @vehicles[2] end |
#airship_land_ok?(x, y) ⇒ Boolean
-
Determine if Airship can Land
495 496 497 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 495 def airship_land_ok?(x, y) check_passage(x, y, 0x0800) && check_passage(x, y, 0x0f) end |
#all_tiles(x, y) ⇒ Object
-
Get Array of All Tiles (Including Events) at Specified Coordinates
462 463 464 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 462 def all_tiles(x, y) tile_events_xy(x, y).collect {|ev| ev.tile_id } + layered_tiles(x, y) end |
#any_event_starting? ⇒ Boolean
-
Determine Existence of Starting Map Event
682 683 684 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 682 def any_event_starting? @events.values.any? {|event| event.starting } end |
#autoplay ⇒ Object
-
Automatically Switch BGM and BGS
327 328 329 330 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 327 def autoplay @map.bgm.play if @map.autoplay_bgm @map.bgs.play if @map.autoplay_bgs end |
#autotile_type(x, y, z) ⇒ Object
-
Get Type of Auto Tile at Specified Coordinates
468 469 470 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 468 def autotile_type(x, y, z) tile_id(x, y, z) >= 2048 ? (tile_id(x, y, z) - 2048) / 48 : -1 end |
#boat ⇒ Object
-
Get Boat
79 80 81 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 79 def boat @vehicles[0] end |
#boat_passable?(x, y) ⇒ Boolean
-
Determine if Passable by Boat
483 484 485 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 483 def boat_passable?(x, y) check_passage(x, y, 0x0200) end |
#bush?(x, y) ⇒ Boolean
-
Determine if Bush
513 514 515 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 513 def bush?(x, y) valid?(x, y) && layered_tiles_flag?(x, y, 0x40) end |
#change_battleback(battleback1_name, battleback2_name) ⇒ Object
-
Change Battle Background
633 634 635 636 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 633 def change_battleback(battleback1_name, battleback2_name) @battleback1_name = battleback1_name @battleback2_name = battleback2_name end |
#change_parallax(name, loop_x, loop_y, sx, sy) ⇒ Object
-
Change Parallax Background
640 641 642 643 644 645 646 647 648 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 640 def change_parallax(name, loop_x, loop_y, sx, sy) @parallax_name = name @parallax_x = 0 if @parallax_loop_x && !loop_x @parallax_y = 0 if @parallax_loop_y && !loop_y @parallax_loop_x = loop_x @parallax_loop_y = loop_y @parallax_sx = sx @parallax_sy = sy end |
#change_tileset(tileset_id) ⇒ Object
-
Change Tileset
626 627 628 629 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 626 def change_tileset(tileset_id) @tileset_id = tileset_id refresh end |
#check_passage(x, y, bit) ⇒ Object
-
Check Passage
bit: Inhibit passage check bit
438 439 440 441 442 443 444 445 446 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 438 def check_passage(x, y, bit) all_tiles(x, y).each do |tile_id| flag = tileset.flags[tile_id] next if flag & 0x10 != 0 # [☆]: No effect on passage return true if flag & bit == 0 # [○] : Passable return false if flag & bit == bit # [×] : Impassable end return false # Impassable end |
#counter?(x, y) ⇒ Boolean
-
Determine if Counter
519 520 521 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 519 def counter?(x, y) valid?(x, y) && layered_tiles_flag?(x, y, 0x80) end |
#create_vehicles ⇒ Object
-
Create Vehicles
55 56 57 58 59 60 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 55 def create_vehicles @vehicles = [] @vehicles[0] = Game_Vehicle.new(:boat) @vehicles[1] = Game_Vehicle.new(:ship) @vehicles[2] = Game_Vehicle.new(:airship) end |
#damage_floor?(x, y) ⇒ Boolean
-
Determine if Damage Floor
525 526 527 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 525 def damage_floor?(x, y) valid?(x, y) && layered_tiles_flag?(x, y, 0x100) end |
#data ⇒ Object
-
Get Map Data
243 244 245 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 243 def data @map.data end |
#disable_dash? ⇒ Boolean
-
Get Whether Dash is Disabled
225 226 227 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 225 def disable_dash? @map.disable_dashing end |
#display_name ⇒ Object
-
Get Display Name
195 196 197 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 195 def display_name @map.display_name end |
#do_scroll(direction, distance) ⇒ Object
-
Execute Scroll
595 596 597 598 599 600 601 602 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 595 def do_scroll(direction, distance) case direction when 2; scroll_down (distance) when 4; scroll_left (distance) when 6; scroll_right(distance) when 8; scroll_up (distance) end end |
#encounter_list ⇒ Object
-
Get Encounter List
231 232 233 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 231 def encounter_list @map.encounter_list end |
#encounter_step ⇒ Object
-
Get Encounter Steps
237 238 239 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 237 def encounter_step @map.encounter_step end |
#event_id_xy(x, y) ⇒ Object
-
Get ID of Events at Designated Coordinates (One Only)
368 369 370 371 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 368 def event_id_xy(x, y) list = events_xy(x, y) list.empty? ? 0 : list[0].id end |
#events_xy(x, y) ⇒ Object
-
Get Array of Events at Designated Coordinates
349 350 351 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 349 def events_xy(x, y) @events.values.select {|event| event.pos?(x, y) } end |
#events_xy_nt(x, y) ⇒ Object
-
Get Array of Events at Designated Coordinates (Except Pass-Through)
355 356 357 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 355 def events_xy_nt(x, y) @events.values.select {|event| event.pos_nt?(x, y) } end |
#height ⇒ Object
-
Get Height
207 208 209 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 207 def height @map.height end |
#ladder?(x, y) ⇒ Boolean
-
Determine if Ladder
507 508 509 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 507 def ladder?(x, y) valid?(x, y) && layered_tiles_flag?(x, y, 0x20) end |
#layered_tiles(x, y) ⇒ Object
-
Get Array of All Layer Tiles (Top to Bottom) at Specified Coordinates
456 457 458 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 456 def layered_tiles(x, y) [2, 1, 0].collect {|z| tile_id(x, y, z) } end |
#layered_tiles_flag?(x, y, bit) ⇒ Boolean
-
Determine Flag for All Layers at Specified Coordinates
501 502 503 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 501 def layered_tiles_flag?(x, y, bit) layered_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 } end |
#loop_horizontal? ⇒ Boolean
-
Loop Horizontally?
213 214 215 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 213 def loop_horizontal? @map.scroll_type == 2 || @map.scroll_type == 3 end |
#loop_vertical? ⇒ Boolean
-
Loop Vertically?
219 220 221 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 219 def loop_vertical? @map.scroll_type == 1 || @map.scroll_type == 3 end |
#map_id ⇒ Object
-
Get Map ID
183 184 185 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 183 def map_id @map_id end |
#overworld? ⇒ Boolean
-
Determine if Field Type
249 250 251 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 249 def overworld? tileset.mode == 0 end |
#parallax_ox(bitmap) ⇒ Object
-
Calculate X Coordinate of Parallax Display Origin
159 160 161 162 163 164 165 166 167 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 159 def parallax_ox(bitmap) if @parallax_loop_x @parallax_x * 16 else w1 = [bitmap.width - Graphics.width, 0].max w2 = [width * 32 - Graphics.width, 1].max @parallax_x * 16 * w1 / w2 end end |
#parallax_oy(bitmap) ⇒ Object
-
Calculate Y Coordinate of Parallax Display Origin
171 172 173 174 175 176 177 178 179 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 171 def parallax_oy(bitmap) if @parallax_loop_y @parallax_y * 16 else h1 = [bitmap.height - Graphics.height, 0].max h2 = [height * 32 - Graphics.height, 1].max @parallax_y * 16 * h1 / h2 end end |
#parallel_common_events ⇒ Object
-
Get Array of Parallel Common Events
110 111 112 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 110 def parallel_common_events $data_common_events.select {|event| event && event.parallel? } end |
#passable?(x, y, d) ⇒ Boolean
-
Determine Passability of Normal Character
d: direction (2,4,6,8) Determines whether the tile at the specified coordinates is passable in the specified direction.
477 478 479 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 477 def passable?(x, y, d) check_passage(x, y, (1 << (d / 2 - 1)) & 0x0f) end |
#referesh_vehicles ⇒ Object
-
Refresh Vehicles
64 65 66 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 64 def referesh_vehicles @vehicles.each {|vehicle| vehicle.refresh } end |
#refresh ⇒ Object
-
Refresh
334 335 336 337 338 339 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 334 def refresh @events.each_value {|event| event.refresh } @common_events.each {|event| event.refresh } refresh_tile_events @need_refresh = false end |
#refresh_tile_events ⇒ Object
-
Refresh Array of Tile-Handling Events
343 344 345 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 343 def refresh_tile_events @tile_events = @events.values.select {|event| event.tile? } end |
#region_id(x, y) ⇒ Object
-
Get Region ID
542 543 544 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 542 def region_id(x, y) valid?(x, y) ? @map.data[x, y, 3] >> 8 : 0 end |
#round_x(x) ⇒ Object
-
Calculate X Coordinate After Loop Adjustment
287 288 289 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 287 def round_x(x) loop_horizontal? ? (x + width) % width : x end |
#round_x_with_direction(x, d) ⇒ Object
-
Calculate X Coordinate Shifted One Tile in Specific Direction (With Loop Adjustment)
314 315 316 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 314 def round_x_with_direction(x, d) round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0)) end |
#round_y(y) ⇒ Object
-
Calculate Y Coordinate After Loop Adjustment
293 294 295 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 293 def round_y(y) loop_vertical? ? (y + height) % height : y end |
#round_y_with_direction(y, d) ⇒ Object
-
Calculate Y Coordinate Shifted One Tile in Specific Direction (With Loop Adjustment)
321 322 323 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 321 def round_y_with_direction(y, d) round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0)) end |
#screen_tile_x ⇒ Object
-
Number of Horizontal Tiles on Screen
255 256 257 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 255 def screen_tile_x Graphics.width / 32 end |
#screen_tile_y ⇒ Object
-
Number of Vertical Tiles on Screen
261 262 263 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 261 def screen_tile_y Graphics.height / 32 end |
#scroll_distance ⇒ Object
-
Calculate Scroll Distance
589 590 591 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 589 def scroll_distance 2 ** @scroll_speed / 256.0 end |
#scroll_down(distance) ⇒ Object
-
Scroll Down
375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 375 def scroll_down(distance) if loop_vertical? @display_y += distance @display_y %= @map.height @parallax_y += distance if @parallax_loop_y else last_y = @display_y @display_y = [@display_y + distance, height - screen_tile_y].min @parallax_y += @display_y - last_y end end |
#scroll_left(distance) ⇒ Object
-
Scroll Left
389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 389 def scroll_left(distance) if loop_horizontal? @display_x += @map.width - distance @display_x %= @map.width @parallax_x -= distance if @parallax_loop_x else last_x = @display_x @display_x = [@display_x - distance, 0].max @parallax_x += @display_x - last_x end end |
#scroll_right(distance) ⇒ Object
-
Scroll Right
403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 403 def scroll_right(distance) if loop_horizontal? @display_x += distance @display_x %= @map.width @parallax_x += distance if @parallax_loop_x else last_x = @display_x @display_x = [@display_x + distance, (width - screen_tile_x)].min @parallax_x += @display_x - last_x end end |
#scroll_up(distance) ⇒ Object
-
Scroll Up
417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 417 def scroll_up(distance) if loop_vertical? @display_y += @map.height - distance @display_y %= @map.height @parallax_y -= distance if @parallax_loop_y else last_y = @display_y @display_y = [@display_y - distance, 0].max @parallax_y += @display_y - last_y end end |
#scrolling? ⇒ Boolean
-
Determine if Scrolling
556 557 558 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 556 def scrolling? @scroll_rest > 0 end |
#set_display_pos(x, y) ⇒ Object
-
Set Display Position
148 149 150 151 152 153 154 155 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 148 def set_display_pos(x, y) x = [0, [x, width - screen_tile_x].min].max unless loop_horizontal? y = [0, [y, height - screen_tile_y].min].max unless loop_vertical? @display_x = (x + width) % width @display_y = (y + height) % height @parallax_x = x @parallax_y = y end |
#setup(map_id) ⇒ Object
-
Setup
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 39 def setup(map_id) @map_id = map_id @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id)) @tileset_id = @map.tileset_id @display_x = 0 @display_y = 0 referesh_vehicles setup_events setup_scroll setup_parallax setup_battleback @need_refresh = false end |
#setup_autorun_common_event ⇒ Object
-
Detect/Set Up Autorun Common Event
697 698 699 700 701 702 703 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 697 def setup_autorun_common_event event = $data_common_events.find do |event| event && event.autorun? && $game_switches[event.switch_id] end @interpreter.setup(event.list) if event event end |
#setup_battleback ⇒ Object
-
Set Up Battle Background
136 137 138 139 140 141 142 143 144 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 136 def setup_battleback if @map.specify_battleback @battleback1_name = @map.battleback1_name @battleback2_name = @map.battleback2_name else @battleback1_name = nil @battleback2_name = nil end end |
#setup_events ⇒ Object
-
Event Setup
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 97 def setup_events @events = {} @map.events.each do |i, event| @events[i] = Game_Event.new(@map_id, event) end @common_events = parallel_common_events.collect do |common_event| Game_CommonEvent.new(common_event.id) end refresh_tile_events end |
#setup_parallax ⇒ Object
-
Parallax Background Setup
124 125 126 127 128 129 130 131 132 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 124 def setup_parallax @parallax_name = @map.parallax_name @parallax_loop_x = @map.parallax_loop_x @parallax_loop_y = @map.parallax_loop_y @parallax_sx = @map.parallax_sx @parallax_sy = @map.parallax_sy @parallax_x = 0 @parallax_y = 0 end |
#setup_scroll ⇒ Object
-
Scroll Setup
116 117 118 119 120 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 116 def setup_scroll @scroll_direction = 2 @scroll_rest = 0 @scroll_speed = 4 end |
#setup_starting_event ⇒ Object
-
Starting Event Setup
672 673 674 675 676 677 678 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 672 def setup_starting_event refresh if @need_refresh return true if @interpreter.setup_reserved_common_event return true if setup_starting_map_event return true if setup_autorun_common_event return false end |
#setup_starting_map_event ⇒ Object
-
Detect/Set Up Starting Map Event
688 689 690 691 692 693 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 688 def setup_starting_map_event event = @events.values.find {|event| event.starting } event.clear_starting_flag if event @interpreter.setup(event.list, event.id) if event event end |
#ship ⇒ Object
-
Get Ship
85 86 87 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 85 def ship @vehicles[1] end |
#ship_passable?(x, y) ⇒ Boolean
-
Determine if Passable by Ship
489 490 491 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 489 def ship_passable?(x, y) check_passage(x, y, 0x0400) end |
#start_scroll(direction, distance, speed) ⇒ Object
-
Start Scroll
548 549 550 551 552 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 548 def start_scroll(direction, distance, speed) @scroll_direction = direction @scroll_rest = distance @scroll_speed = speed end |
#terrain_tag(x, y) ⇒ Object
-
Get Terrain Tag
531 532 533 534 535 536 537 538 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 531 def terrain_tag(x, y) return 0 unless valid?(x, y) layered_tiles(x, y).each do |tile_id| tag = tileset.flags[tile_id] >> 12 return tag if tag > 0 end return 0 end |
#tile_events_xy(x, y) ⇒ Object
-
Get Array of Tile-Handling Events at Designated Coordinates (Except Pass-Through)
362 363 364 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 362 def tile_events_xy(x, y) @tile_events.select {|event| event.pos_nt?(x, y) } end |
#tile_id(x, y, z) ⇒ Object
-
Get Tile ID at Specified Coordinates
450 451 452 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 450 def tile_id(x, y, z) @map.data[x, y, z] || 0 end |
#tileset ⇒ Object
-
Get Tileset
189 190 191 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 189 def tileset $data_tilesets[@tileset_id] end |
#unlock_event(event_id) ⇒ Object
-
Unlock Event
666 667 668 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 666 def unlock_event(event_id) @events[event_id].unlock if @events[event_id] end |
#update(main = false) ⇒ Object
-
Frame Update
main: Interpreter update flag
563 564 565 566 567 568 569 570 571 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 563 def update(main = false) refresh if @need_refresh update_interpreter if main update_scroll update_events update_vehicles update_parallax @screen.update end |
#update_events ⇒ Object
-
Update Events
606 607 608 609 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 606 def update_events @events.each_value {|event| event.update } @common_events.each {|event| event.update } end |
#update_interpreter ⇒ Object
-
Update Interpreter
652 653 654 655 656 657 658 659 660 661 662 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 652 def update_interpreter loop do @interpreter.update return if @interpreter.running? if @interpreter.event_id > 0 unlock_event(@interpreter.event_id) @interpreter.clear end return unless setup_starting_event end end |
#update_parallax ⇒ Object
-
Update Parallax
619 620 621 622 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 619 def update_parallax @parallax_x += @parallax_sx / 64.0 if @parallax_loop_x @parallax_y += @parallax_sy / 64.0 if @parallax_loop_y end |
#update_scroll ⇒ Object
-
Update Scroll
575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 575 def update_scroll return unless scrolling? last_x = @display_x last_y = @display_y do_scroll(@scroll_direction, scroll_distance) if @display_x == last_x && @display_y == last_y @scroll_rest = 0 else @scroll_rest -= scroll_distance end end |
#update_vehicles ⇒ Object
-
Update Vehicles
613 614 615 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 613 def update_vehicles @vehicles.each {|vehicle| vehicle.update } end |
#valid?(x, y) ⇒ Boolean
-
Determine Valid Coordinates
431 432 433 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 431 def valid?(x, y) x >= 0 && x < width && y >= 0 && y < height end |
#vehicle(type) ⇒ Object
-
Get Vehicle
70 71 72 73 74 75 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 70 def vehicle(type) return @vehicles[0] if type == :boat return @vehicles[1] if type == :ship return @vehicles[2] if type == :airship return nil end |
#width ⇒ Object
-
Get Width
201 202 203 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 201 def width @map.width end |
#x_with_direction(x, d) ⇒ Object
-
Calculate X Coordinate Shifted One Tile in Specific Direction (No Loop Adjustment)
300 301 302 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 300 def x_with_direction(x, d) x + (d == 6 ? 1 : d == 4 ? -1 : 0) end |
#y_with_direction(y, d) ⇒ Object
-
Calculate Y Coordinate Shifted One Tile in Specific Direction (No Loop Adjustment)
307 308 309 |
# File 'lib/rgss3_default_scripts/Game_Map.rb', line 307 def y_with_direction(y, d) y + (d == 2 ? 1 : d == 8 ? -1 : 0) end |