RPG Maker
 

 Username:
 Password:
   Not a member? Register!

Home > RGSS Script Reference > Scene_Map

Scene_Map


Inherits from: None

Description: This class handles the scene-related elements of the map, such as setting up the message window and calling various menus that would change the "Scene". Other duties, such as processing of map graphics and map events, are handled by the Game_Map class and its member objects.

Code


class Scene_Map
# ------------------------------------
  def main
    @spriteset = Spriteset_Map.new
    @message_window = Window_Message.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @spriteset.dispose
    @message_window.dispose
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
  end
# ------------------------------------  
  def update
    loop do
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      $game_system.update
      $game_screen.update
      unless $game_temp.player_transferring
        break
      end
      transfer_player
      if $game_temp.transition_processing
        break
      end
    end
    @spriteset.update
    @message_window.update
    if $game_temp.gameover
      $scene = Scene_Gameover.new
      return
    end
    if $game_temp.to_title
      $scene = Scene_Title.new
      return
    end
    if $game_temp.transition_processing
      $game_temp.transition_processing = false
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    if $game_temp.message_window_showing
      return
    end
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        $game_temp.battle_calling = true
        $game_temp.battle_can_escape = true
        $game_temp.battle_can_lose = false
        $game_temp.battle_proc = nil
        n = rand($game_map.encounter_list.size)
        $game_temp.battle_troop_id = $game_map.encounter_list[n]
      end
    end
    if Input.trigger?(Input::B)
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    if $DEBUG and Input.press?(Input::F9)
      $game_temp.debug_calling = true
    end
    unless $game_player.moving?
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
# ------------------------------------  
  def call_battle
    $game_temp.battle_calling = false
    $game_temp.menu_calling = false
    $game_temp.menu_beep = false
    $game_player.make_encounter_count
    $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
    $game_system.se_play($data_system.battle_start_se)
    $game_system.bgm_play($game_system.battle_bgm)
    $game_player.straighten
    $scene = Scene_Battle.new
  end
# ------------------------------------
  def call_shop
    $game_temp.shop_calling = false
    $game_player.straighten
    $scene = Scene_Shop.new
  end
# ------------------------------------
  def call_name
    $game_temp.name_calling = false
    $game_player.straighten
    $scene = Scene_Name.new
  end
# ------------------------------------
  def call_menu
    $game_temp.menu_calling = false
    if $game_temp.menu_beep
      $game_system.se_play($data_system.decision_se)
      $game_temp.menu_beep = false
    end
    $game_player.straighten
    $scene = Scene_Menu.new
  end
# ------------------------------------
  def call_save
    $game_player.straighten
    $scene = Scene_Save.new
  end
# ------------------------------------
  def call_debug
    $game_temp.debug_calling = false
    $game_system.se_play($data_system.decision_se)
    $game_player.straighten
    $scene = Scene_Debug.new
  end
# ------------------------------------
  def transfer_player
    $game_temp.player_transferring = false
    if $game_map.map_id != $game_temp.player_new_map_id
      $game_map.setup($game_temp.player_new_map_id)
    end
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    case $game_temp.player_new_direction
    when 2
      $game_player.turn_down
    when 4
      $game_player.turn_left
    when 6
      $game_player.turn_right
    when 8
      $game_player.turn_up
    end
    $game_player.straighten
    $game_map.update
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    if $game_temp.transition_processing
      $game_temp.transition_processing = false
      Graphics.transition(20)
    end
    $game_map.autoplay
    Graphics.frame_reset
    Input.update
  end
end 

Properties


Spriteset: A set of map sprites, such as the viewports for each map layer, the panorama graphic, and the fog graphic.

Message_Window: A Window_Message object for showing messages.

Methods


Main

Arguments: None
Local Variables: None

How it Works: This is the main method for this class. It first sets up the spriteset and the message window. Then, we come to the familiar main loop that updates the graphics, updates the input buffer, and updates the scene itself. Once the value of $Scene has changed, the rest of the method disposes of the spriteset and message window. If the Scene is now the title screen, the graphics are frozen.

Update

Arguments: None
Local Variables: None

How it Works: This method updates the map contents and processes input from the player. The body of the method begins with a loop. This loop updates the map graphics, interpreter, player, system, and screen. Note that the interpreter is updated before the player so that the player doesn't have an opportunity to move if the conditions for one or more events became true. If the player isn't in the process of teleporting, the loop breaks and proceeds to the @spriteset.update statement. If a teleport is waiting, then the Transfer_Player method is called. If there is a transition process occuring, the loop then breaks. Once out of the loop, the spriteset and message window are updated. The next few statements are conditional checks. If the value of $game_temp.gameover is true, then control is transferred to the Game Over screen. If the value of if $game_temp.to_title is true, then control is transferred to the title screen. If a transition is pending, then the transition processing flag is cleared. If the transition name is "" (null string), then the built-in fade transition is triggered. If a name has been specified, then the transition with that name is processed. If the $game_temp.message_showing flag is set, the method returns, since none of the statements below this one should be executed if a message window is showing. The if $game_player.encounter_count == 0 and $game_map.encounter_list != [] statement checks to see if an encounter is pending because the encounter step counter has reached 0. If an encounter is pending, then the method checks to see if a non-parallel event is executing or encounters are disabled. If either is true, nothing happens. If neither are true, then a "default" battle is generated (able to escape, no defeat handler). The monster group to fight is then chosen using a random number generator. The next statement checks to see if the user has pressed "B" (cancel key). If he has, then the menu is called unless an event is running or the menu has been disabled. If the test play flag ($DEBUG) is set, then the debug menu is called if the user has pressed F9. The final part of the method checks to see if any other scenes have been called as a result of event commands such as Open Shop Window, Enemy Encounter, Open Main Menu, or Open Save Menu. If any of flags associated with calling other scenes are set, control is transferred to that scene as soon as the player finishes moving.

Call_Battle

Arguments: None
Local Variables: None

How it Works: This method calls the battle screen. First, the battle pending flag and menu call flags are cleared. The encounter count is then reset (even if this isn't a random encounter). The $game_temp.map_bgm = $game_system.playing_bgm statement saves the current map BGM so that it can be recalled when the battle concludes. The BGM is then replaced with the battle BGM declared in the System tab of the database. The player is straightened, and control is transferred to the battle screen.

Call_Shop

Arguments: None
Local Variables: None

How it Works: This method opens the shop window as a result of the "Open Shop Window" event command. It clears the Shop Called flag, straightens the player, and transfers control to the shop window.

Call_Name

Arguments: None
Local Variables: None

How it Works: This method opens the hero naming window as a result of the "Enter Hero Name" event command. It clears the Enter Hero Name flag, straightens the player, and transfers control to the naming window.

Call_Menu

Arguments: None
Local Variables: None

How it Works: This method opens the main menu as a result of the "Open Main Menu" event command being used, or the player pressing the cancel key on the map screen. It first clears the Menu Called flag. If the $game_temp.menu_beep flag is set, the decision sound effect is played and the flag is unset. Note that this flag is only set if the player called the menu by pressing the cancel key on the map screen. Calling the menu via event commands will not cause this flag to be set. The player is then straightened, and control is transferred to the menu screen.

Call_Save

Arguments: None
Local Variables: None

How it Works: This method opens the save menu as a result of the "Open Save menu" event command or choosing the "save" command from the main menu. It straightens the player, and transfers control to the save menu.

Call_Debug

Arguments: None
Local Variables: None

How it Works: This method opens the debug window when the player pressed F9 during Test Play. It clears the Debug Call flag, straightens the player, plays a decision sound effect, and transfers control to the debug window.

Transfer_Player

Arguments: None
Local Variables: None

How it Works: This method handles teleporting the player. This method differs from Game_Player#Moveto in that it supporting changing maps. First, the Player Teleporting flag is cleared. If the destination map ID differs from the current map ID, then the new map is set up. Note that in this case, the same Scene_Map object is used to contain the new map. Once the new map is set up, the Game_Player#Moveto method takes care of the intramap movement to the new X and Y coordinates. The next four statements change the player's facing if a specific facing was specified in the Teleport command. Note what happens after the map is updated. The spriteset is disposed of and a new one is created, whether the map changed or not. This is important because even if the teleport did not cause the player to change maps, the fog position and the like will be reset. The if $game_temp.transition_processing statement checks to see if a transition is processing. If one isn't, then the screen transitions on its own. The $game_map.autoplay method checks the map's automatic BGM settings, and plays the BGM that is set for the new map. The input is then updated. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the Terms of Use.
©2004 - 2008 RPG RPG Revolution, All Rights Reserved. Contact Us · Privacy Policy · Legal Disclaimer
eXTReMe Tracker