设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 15020|回复: 47
打印 上一主题 下一主题

[原创发布] RMXP SDK(震撼登场)

 关闭 [复制链接]

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

跳转到指定楼层
1
发表于 2005-12-21 22:04:12 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
下载地址:
http://rpg.blue/web/dlFTP/up/技术区/RMXP SDK 1.2.txt

http://rpg.blue/web/dlFTP/up/技术区/RMXP SDK 1.3.txt

#==============================================================================
# ** RMXP Standard Development Kit (SDK)
#------------------------------------------------------------------------------
# Build Date - 2005-11-22
# Version 1.0 - Near Fantastica - 2005-11-22
# Version 1.1 - SephirothSpawn - 2005-12-18 - (Near Fantastica)
# Version 1.2 - Near Fantastica - 2005-12-18
# Version 1.3 - Wachunga - 2005-12-19
#------------------------------------------------------------------------------
=begin
  1.0 - Outline

  The Standard Development Kit (SDK) aims to increase compatibility between
  RGSS scripts by:

  a) defining a set of scripting standards (see section 3)
  b) restructuring often-used default classes and methods (see section 4)
  c) providing a scripting tools module (see section 5)
#------------------------------------------------------------------------------
  2.0 - Modifications to the RMXP Standard Development Kit

  Since edits to the SDK may cause massive capability errors, any and all
  modifications must first be approved by a member of the RMXP SDK Team.

  The author of any modifications must be sure to update all relevant
  documentation. This also includes the header, where the author is to put
  the next version number with his or her name and the name of the approval
  member (from the SDK Team) under the latest version in the following format.

  Version # - Name - Date - (Approval Member Name)
#------------------------------------------------------------------------------
  3.0 - Coding Standards

  To be compliant with the SDK, a script must compy with the following
  coding standards:

  3.1 - Commenting
  3.2 - Classes
  3.3 - Variables
  3.4 - Aliases
  3.5 - Strings
  3.6 - Line Length
  3.7 - White Space
  3.8 - Constants
  3.9 - Parentheses
#------------------------------------------------------------------------------
  3.1 - Commenting

  Scripts must begin with the following header:

  #==============================================================================
  # ** Script Name
  #------------------------------------------------------------------------------
  # Your Name
  # Version
  # Date
  #==============================================================================

  All classes and methods must have a comment describing the process or what
  was added. All code added to methods that can not be aliased must be
  formatted as follows:

  #------------------------------------------------------------------------------
  # Begin Script Name Edit
  #------------------------------------------------------------------------------
  [Code]  
  #------------------------------------------------------------------------------
  # End Script Name Edit
  #------------------------------------------------------------------------------

  Single line comments should precede the described block of code and should be
  indented at the same level. Code that is not self-documenting should be
  commented.
  
  However, very short comments can appear on the same line as the described
  code, but should be shifted far enough to separate them from the statements.
  If more than one short comment appears in a chunk of code, they should all be
  indented to the same tab setting. Attribute declarations should always have a
  trailing comment.
#------------------------------------------------------------------------------
  3.2 - Classes

  All classes must be named consistently with the default code, namely:

    Data - Any class that holds data
    Game - Any class that processes data
    Sprite - Any class that defines a sprite
    Spriteset - Any class that defines multiple sprites
    Window - Any class that defines a window
    Arrow - Any class that defines an arrow
    Scene - Any class that defines a scene
#------------------------------------------------------------------------------
  3.3 - Variables

  All variable names must be reasonably descriptive. Use of class and global
  variables should be limited. Any variable used by the default system can not
  have its use changed.
#------------------------------------------------------------------------------
  3.4 - Aliases

  Aliasing a method is preferable to overriding it; an alias should be used
  whenever possible to increase compatibility with other scripts. All alias
  names must have the following format:

  yourname_scriptname_classname_methodname
#------------------------------------------------------------------------------
  3.5 ?Strings

  Strings should normally be defined with single quotes ('example'); this
  decreases the processing time of the engine. Double quotes are useful when
  using the following features:
  a) substitutions, i.e. sequences that start with a backslash character
     (e.g. \n for the newline character)
  b) expression interpolation, i.e. #{ expression } is replaced by the value
     of expression
#------------------------------------------------------------------------------
  3.6 - Line Length
  
  Lines should not cause the the viewer to have to scroll sideways to view them
  in the script editor. When the line needs to be broken, it should follow the
  following guidelines, in preferential order:
  
    Break after a comma.
    Break before an operator.
    Prefer higher-level breaks to lower-level breaks.
    Align the new line with the beginning of the expression at the same level
    on the previous line.
  
  If the above rules lead to confusing code or to code that抯 squished up
  against the right margin, just indent 4 spaces instead.
#------------------------------------------------------------------------------
  3.7 - White Space
  
  A blank line(s) should be used in the following places:
  
    Between sections of a source file
    Between class and module definitions
    Between attributes and the class definition
    Between methods
    Between the local variables in a method and its first statement
    Before a block or single-line comment
    Between logical sections inside a method to improve readability

  Blank spaces should be used in the following places:
  
    A keyword followed by a parenthesis, e.g. if (some_boolean_statements)
    After commas in argument lists, e.g. def method (arg1, arg2, ...)
    All binary operators except '.', e.g. a + b; c = 1
#------------------------------------------------------------------------------
  3.8 - Constants
  
  New numerical values should not be "hard-coded", except for -1, 0, and 1,
  which can appear in for loops as counter values. Instead, these numerical
  values should be made into constant variables and these used instead.
#------------------------------------------------------------------------------
  3.9 - Parentheses
  
  It is generally a good idea to use parentheses liberally in expressions
  involving mixed operators to avoid operator precedence problems. Even if
  the operator precedence seems clear to you, it might not be to others -?you
  shouldn抰 assume that other programmers know precedence as well as you do.
#------------------------------------------------------------------------------
  4.0 - Engine Updates

  The following is a list of classes and methods that have been updated by the
  SDK to help improve compatibility:

    Game_Map - setup
    Game_Map - update
    Game_Character - update
    Game_Event - refresh
    Game_Player - update
    Spriteset_Map - initialize
    Spriteset_Map - update
    Scene_Tile - main
    Scene_Map - main
    Scene_Map - update
    Scene_Save - write_save_data
    Scene_Load - read_save_data
    Scene_Menu - initialize   
    Scene_Menu - main
    Scene_Menu - update & command input
    Scene_Battle - main
    Scene_Battle - update
    Scene_Battle - update_phase3_basic_command
    Scene_Battle - make_basic_action_result
#------------------------------------------------------------------------------
  5.0 - SDK Tools

  The following tools are included in the SDK to help improve the development
  process:

  5.1 - Logging Scripts
  5.2 - Enabling/Disabling Scripts
  5.3 - Script Dependencies
  5.4 - Standard Text Box Input
  5.5 - Standard Event Comment Input
#------------------------------------------------------------------------------
  5.1 ?Logging Scripts

  All SDK-compliant scripts should be logged. This is done by calling the
  SDK.log(script, name, ver, date) method, where

  script = script name
  name = your name
  ver = version
  date = date last updated
#------------------------------------------------------------------------------
  5.2 ?Enabling/Disabling Scripts

  When a script is logged it is also enabled. A script can be enabled and
  disabled using the following calls:

  SDK.enable('Script Name')
  SDK.disable('Script Name')

  All non-default scripts (and code added to default scripts) must be enclosed
  in an if statement that checks whether or not they have been enabled, as
  follows:
  
  #--------------------------------------------------------------------------
  # Begin SDK Enabled Check
  #--------------------------------------------------------------------------
  if SDK.state('Script Name') == true
    [Script or Code]
  end
  #--------------------------------------------------------------------------
  # End SDK Enabled Test
  #--------------------------------------------------------------------------

  Keep in mind that this if statement can not continue on to other pages and
  every page needs its own if statement testing the state of the script. As
  well every script should have its own test.
#------------------------------------------------------------------------------
  5.3 ?Script Dependencies

  Any script that requires (i.e. has a dependency on) another script can check
  if that dependency is met provided that the required script is set up before
  the script in question. This would be done in the following way:

  p 'Script Name not found' if SDK.state('Script Name') != true
#------------------------------------------------------------------------------
  5.4 ?Standard Text Box Input
  
  Any script that requires input from a database text field should use the
  following:
  
  SDK.text_box_input(element, index)
  
  where:
  element = an object of the text field
  index = the index in which your script call falls
   
  The text field should be formatted in the following way:
  
  "Default value | script call | script call"
#------------------------------------------------------------------------------
  5.5 ?Standard Event Comment Input
  
  Any script that requires input from an event comment should use the
  following:
  
  SDK.event_comment_input(event, elements, trigger)
  
  where:
  event = an object of the event
  elements = the number of elements the method is to process
  trigger = the text value triggering the script to start processing
  
  or
  
  SDK.event_comment_input(page, elements, trigger)
  
  where:
  page = an object of the event.page
  elements = the number of elements the method is to process
  trigger = the text value triggering the script to start processing
  
  The method returns nil if the trigger can not be found; otherwise, it
  returns a list of the parameters from the event.
#==============================================================================
=end

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

2
 楼主| 发表于 2005-12-21 22:04:12 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
下载地址:
http://rpg.blue/web/dlFTP/up/技术区/RMXP SDK 1.2.txt

http://rpg.blue/web/dlFTP/up/技术区/RMXP SDK 1.3.txt

#==============================================================================
# ** RMXP Standard Development Kit (SDK)
#------------------------------------------------------------------------------
# Build Date - 2005-11-22
# Version 1.0 - Near Fantastica - 2005-11-22
# Version 1.1 - SephirothSpawn - 2005-12-18 - (Near Fantastica)
# Version 1.2 - Near Fantastica - 2005-12-18
# Version 1.3 - Wachunga - 2005-12-19
#------------------------------------------------------------------------------
=begin
  1.0 - Outline

  The Standard Development Kit (SDK) aims to increase compatibility between
  RGSS scripts by:

  a) defining a set of scripting standards (see section 3)
  b) restructuring often-used default classes and methods (see section 4)
  c) providing a scripting tools module (see section 5)
#------------------------------------------------------------------------------
  2.0 - Modifications to the RMXP Standard Development Kit

  Since edits to the SDK may cause massive capability errors, any and all
  modifications must first be approved by a member of the RMXP SDK Team.

  The author of any modifications must be sure to update all relevant
  documentation. This also includes the header, where the author is to put
  the next version number with his or her name and the name of the approval
  member (from the SDK Team) under the latest version in the following format.

  Version # - Name - Date - (Approval Member Name)
#------------------------------------------------------------------------------
  3.0 - Coding Standards

  To be compliant with the SDK, a script must compy with the following
  coding standards:

  3.1 - Commenting
  3.2 - Classes
  3.3 - Variables
  3.4 - Aliases
  3.5 - Strings
  3.6 - Line Length
  3.7 - White Space
  3.8 - Constants
  3.9 - Parentheses
#------------------------------------------------------------------------------
  3.1 - Commenting

  Scripts must begin with the following header:

  #==============================================================================
  # ** Script Name
  #------------------------------------------------------------------------------
  # Your Name
  # Version
  # Date
  #==============================================================================

  All classes and methods must have a comment describing the process or what
  was added. All code added to methods that can not be aliased must be
  formatted as follows:

  #------------------------------------------------------------------------------
  # Begin Script Name Edit
  #------------------------------------------------------------------------------
  [Code]  
  #------------------------------------------------------------------------------
  # End Script Name Edit
  #------------------------------------------------------------------------------

  Single line comments should precede the described block of code and should be
  indented at the same level. Code that is not self-documenting should be
  commented.
  
  However, very short comments can appear on the same line as the described
  code, but should be shifted far enough to separate them from the statements.
  If more than one short comment appears in a chunk of code, they should all be
  indented to the same tab setting. Attribute declarations should always have a
  trailing comment.
#------------------------------------------------------------------------------
  3.2 - Classes

  All classes must be named consistently with the default code, namely:

    Data - Any class that holds data
    Game - Any class that processes data
    Sprite - Any class that defines a sprite
    Spriteset - Any class that defines multiple sprites
    Window - Any class that defines a window
    Arrow - Any class that defines an arrow
    Scene - Any class that defines a scene
#------------------------------------------------------------------------------
  3.3 - Variables

  All variable names must be reasonably descriptive. Use of class and global
  variables should be limited. Any variable used by the default system can not
  have its use changed.
#------------------------------------------------------------------------------
  3.4 - Aliases

  Aliasing a method is preferable to overriding it; an alias should be used
  whenever possible to increase compatibility with other scripts. All alias
  names must have the following format:

  yourname_scriptname_classname_methodname
#------------------------------------------------------------------------------
  3.5 ?Strings

  Strings should normally be defined with single quotes ('example'); this
  decreases the processing time of the engine. Double quotes are useful when
  using the following features:
  a) substitutions, i.e. sequences that start with a backslash character
     (e.g. \n for the newline character)
  b) expression interpolation, i.e. #{ expression } is replaced by the value
     of expression
#------------------------------------------------------------------------------
  3.6 - Line Length
  
  Lines should not cause the the viewer to have to scroll sideways to view them
  in the script editor. When the line needs to be broken, it should follow the
  following guidelines, in preferential order:
  
    Break after a comma.
    Break before an operator.
    Prefer higher-level breaks to lower-level breaks.
    Align the new line with the beginning of the expression at the same level
    on the previous line.
  
  If the above rules lead to confusing code or to code that抯 squished up
  against the right margin, just indent 4 spaces instead.
#------------------------------------------------------------------------------
  3.7 - White Space
  
  A blank line(s) should be used in the following places:
  
    Between sections of a source file
    Between class and module definitions
    Between attributes and the class definition
    Between methods
    Between the local variables in a method and its first statement
    Before a block or single-line comment
    Between logical sections inside a method to improve readability

  Blank spaces should be used in the following places:
  
    A keyword followed by a parenthesis, e.g. if (some_boolean_statements)
    After commas in argument lists, e.g. def method (arg1, arg2, ...)
    All binary operators except '.', e.g. a + b; c = 1
#------------------------------------------------------------------------------
  3.8 - Constants
  
  New numerical values should not be "hard-coded", except for -1, 0, and 1,
  which can appear in for loops as counter values. Instead, these numerical
  values should be made into constant variables and these used instead.
#------------------------------------------------------------------------------
  3.9 - Parentheses
  
  It is generally a good idea to use parentheses liberally in expressions
  involving mixed operators to avoid operator precedence problems. Even if
  the operator precedence seems clear to you, it might not be to others -?you
  shouldn抰 assume that other programmers know precedence as well as you do.
#------------------------------------------------------------------------------
  4.0 - Engine Updates

  The following is a list of classes and methods that have been updated by the
  SDK to help improve compatibility:

    Game_Map - setup
    Game_Map - update
    Game_Character - update
    Game_Event - refresh
    Game_Player - update
    Spriteset_Map - initialize
    Spriteset_Map - update
    Scene_Tile - main
    Scene_Map - main
    Scene_Map - update
    Scene_Save - write_save_data
    Scene_Load - read_save_data
    Scene_Menu - initialize   
    Scene_Menu - main
    Scene_Menu - update & command input
    Scene_Battle - main
    Scene_Battle - update
    Scene_Battle - update_phase3_basic_command
    Scene_Battle - make_basic_action_result
#------------------------------------------------------------------------------
  5.0 - SDK Tools

  The following tools are included in the SDK to help improve the development
  process:

  5.1 - Logging Scripts
  5.2 - Enabling/Disabling Scripts
  5.3 - Script Dependencies
  5.4 - Standard Text Box Input
  5.5 - Standard Event Comment Input
#------------------------------------------------------------------------------
  5.1 ?Logging Scripts

  All SDK-compliant scripts should be logged. This is done by calling the
  SDK.log(script, name, ver, date) method, where

  script = script name
  name = your name
  ver = version
  date = date last updated
#------------------------------------------------------------------------------
  5.2 ?Enabling/Disabling Scripts

  When a script is logged it is also enabled. A script can be enabled and
  disabled using the following calls:

  SDK.enable('Script Name')
  SDK.disable('Script Name')

  All non-default scripts (and code added to default scripts) must be enclosed
  in an if statement that checks whether or not they have been enabled, as
  follows:
  
  #--------------------------------------------------------------------------
  # Begin SDK Enabled Check
  #--------------------------------------------------------------------------
  if SDK.state('Script Name') == true
    [Script or Code]
  end
  #--------------------------------------------------------------------------
  # End SDK Enabled Test
  #--------------------------------------------------------------------------

  Keep in mind that this if statement can not continue on to other pages and
  every page needs its own if statement testing the state of the script. As
  well every script should have its own test.
#------------------------------------------------------------------------------
  5.3 ?Script Dependencies

  Any script that requires (i.e. has a dependency on) another script can check
  if that dependency is met provided that the required script is set up before
  the script in question. This would be done in the following way:

  p 'Script Name not found' if SDK.state('Script Name') != true
#------------------------------------------------------------------------------
  5.4 ?Standard Text Box Input
  
  Any script that requires input from a database text field should use the
  following:
  
  SDK.text_box_input(element, index)
  
  where:
  element = an object of the text field
  index = the index in which your script call falls
   
  The text field should be formatted in the following way:
  
  "Default value | script call | script call"
#------------------------------------------------------------------------------
  5.5 ?Standard Event Comment Input
  
  Any script that requires input from an event comment should use the
  following:
  
  SDK.event_comment_input(event, elements, trigger)
  
  where:
  event = an object of the event
  elements = the number of elements the method is to process
  trigger = the text value triggering the script to start processing
  
  or
  
  SDK.event_comment_input(page, elements, trigger)
  
  where:
  page = an object of the event.page
  elements = the number of elements the method is to process
  trigger = the text value triggering the script to start processing
  
  The method returns nil if the trigger can not be found; otherwise, it
  returns a list of the parameters from the event.
#==============================================================================
=end

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

3
 楼主| 发表于 2005-12-21 22:09:27 | 显示全部楼层

  1. module SDK
  2.   @list = {}
  3.   @enabled = {}
  4.   #--------------------------------------------------------------------------
  5.   # * Logs a custom script
  6.   #--------------------------------------------------------------------------
  7.   def self.log(script, name, ver, date)
  8.     @list[script] = [name,ver,date]
  9.     @enabled[script] = true
  10.   end
  11.   #--------------------------------------------------------------------------
  12.   # * Returns a list of custom scripts
  13.   #--------------------------------------------------------------------------
  14.   def self.print(script = '')
  15.     if script == ''
  16.       return @list
  17.     else
  18.       return @list[script]
  19.     end
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # * Writes a list of the custom scripts to a file
  23.   #--------------------------------------------------------------------------
  24.   def self.write
  25.     file = File.open('Scripts List.txt', 'wb')
  26.     for key in @list.keys
  27.       file.write("#{@list[key][0]} : #{key} Version #{@list[key][1]}\n")
  28.     end
  29.     file.close
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # * Returns the state of the passed script
  33.   #--------------------------------------------------------------------------
  34.   def self.state(script)
  35.     return @enabled[script]
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # * Enables the passed script
  39.   #--------------------------------------------------------------------------
  40.   def self.enable(script)
  41.     @enabled[script] = true
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # * Disables the passed script
  45.   #--------------------------------------------------------------------------
  46.   def self.disable(script)
  47.     @enabled[script] = false
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # * Evals text from an input source
  51.   #--------------------------------------------------------------------------
  52.   def self.text_box_input(element, index)
  53.     return if index == 0
  54.     commands = element.split('|')
  55.     eval(commands[index])
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # * Returns a list of parameters from an event's comments
  59.   #--------------------------------------------------------------------------
  60.   def self.event_comment_input(*args)
  61.     parameters = []
  62.     list = *args[0].list
  63.     elements = *args[1]
  64.     trigger = *args[2]
  65.     return nil if list == nil
  66.     return nil unless list.is_a?(Array)
  67.     for item in list
  68.       next if item.code != 108
  69.       if item.parameters[0] == trigger
  70.         start = list.index(item) + 1
  71.         finish = start + elements
  72.         for id in start...finish
  73.           next if !list[id]
  74.           parameters.push(list[id].parameters[0])
  75.         end
  76.         return parameters
  77.       end
  78.     end
  79.     return nil
  80.   end
  81. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

4
 楼主| 发表于 2005-12-21 22:10:09 | 显示全部楼层

  1. #==============================================================================
  2. # ** Object
  3. #------------------------------------------------------------------------------
  4. # automatic_dispose looks after disposing all windows and sprites in a scene
  5. # when called.
  6. #==============================================================================

  7. class Object
  8.   #--------------------------------------------------------------------------
  9.   # * Automatic Dispose
  10.   #--------------------------------------------------------------------------
  11.   def automatic_dispose
  12.     self.instance_variables.each do |item|
  13.       eval("#{item}.dispose if (#{item}.is_a?(Sprite) or #{item}.is_a?(Window_Base)) and (!#{item}.disposed?)")
  14.     end
  15.   end
  16. end

  17. #==============================================================================
  18. # ** Game_Map
  19. #------------------------------------------------------------------------------
  20. #  This class handles the map. It includes scrolling and passable determining
  21. #  functions. Refer to "$game_map" for the instance of this class.
  22. #==============================================================================

  23. class Game_Map
  24.   #--------------------------------------------------------------------------
  25.   # * Setup
  26.   #     map_id : map ID
  27.   #--------------------------------------------------------------------------
  28.   def setup(map_id)
  29.     setup_map_id(map_id)
  30.     setup_load
  31.     setup_tileset
  32.     setup_display
  33.     setup_refresh
  34.     setup_events
  35.     setup_common_events
  36.     setup_fog
  37.     setup_scroll
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # * Setup Map ID
  41.   #--------------------------------------------------------------------------
  42.   def setup_map_id(map_id)
  43.     # Put map ID in @map_id memory
  44.     @map_id = map_id
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # * Load Map Data
  48.   #--------------------------------------------------------------------------
  49.   def setup_load
  50.     # Load map from file and set @map
  51.     @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # * Setup Tileset
  55.   #--------------------------------------------------------------------------
  56.   def setup_tileset
  57.     # set tile set information in opening instance variables
  58.     tileset = $data_tilesets[@map.tileset_id]
  59.     @tileset_name = tileset.tileset_name
  60.     @autotile_names = tileset.autotile_names
  61.     @panorama_name = tileset.panorama_name
  62.     @panorama_hue = tileset.panorama_hue
  63.     @fog_name = tileset.fog_name
  64.     @fog_hue = tileset.fog_hue
  65.     @fog_opacity = tileset.fog_opacity
  66.     @fog_blend_type = tileset.fog_blend_type
  67.     @fog_zoom = tileset.fog_zoom
  68.     @fog_sx = tileset.fog_sx
  69.     @fog_sy = tileset.fog_sy
  70.     @battleback_name = tileset.battleback_name
  71.     @passages = tileset.passages
  72.     @priorities = tileset.priorities
  73.     @terrain_tags = tileset.terrain_tags
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Setup Display
  77.   #--------------------------------------------------------------------------
  78.   def setup_display
  79.     # Initialize displayed coordinates
  80.     @display_x = 0
  81.     @display_y = 0
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # * Setup Refresh
  85.   #--------------------------------------------------------------------------
  86.   def setup_refresh
  87.     # Clear refresh request flag
  88.     @need_refresh = false
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Setup Events
  92.   #--------------------------------------------------------------------------
  93.   def setup_events
  94.     # Set map event data
  95.     @events = {}
  96.     for i in @map.events.keys
  97.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Setup Common Events
  102.   #--------------------------------------------------------------------------
  103.   def setup_common_events
  104.     # Set common event data
  105.     @common_events = {}
  106.     for i in 1...$data_common_events.size
  107.       @common_events[i] = Game_CommonEvent.new(i)
  108.     end
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Setup Fog
  112.   #--------------------------------------------------------------------------
  113.   def setup_fog
  114.     # Initialize all fog information
  115.     @fog_ox = 0
  116.     @fog_oy = 0
  117.     @fog_tone = Tone.new(0, 0, 0, 0)
  118.     @fog_tone_target = Tone.new(0, 0, 0, 0)
  119.     @fog_tone_duration = 0
  120.     @fog_opacity_duration = 0
  121.     @fog_opacity_target = 0
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Setup Scroll
  125.   #--------------------------------------------------------------------------
  126.   def setup_scroll
  127.     # Initialize scroll information
  128.     @scroll_direction = 2
  129.     @scroll_rest = 0
  130.     @scroll_speed = 4
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * Frame Update
  134.   #--------------------------------------------------------------------------
  135.   def update
  136.     update_refresh
  137.     update_scrolling
  138.     update_events
  139.     update_common_events
  140.     update_fog_scroll
  141.     update_fog_colour
  142.     update_fog
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # * Refresh Game Map
  146.   #--------------------------------------------------------------------------
  147.   def update_refresh
  148.     # Refresh map if necessary
  149.     if $game_map.need_refresh
  150.       refresh
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Update Scrolling
  155.   #--------------------------------------------------------------------------
  156.   def update_scrolling
  157.     # If scrolling
  158.     if @scroll_rest > 0
  159.       # Change from scroll speed to distance in map coordinates
  160.       distance = 2 ** @scroll_speed
  161.       # Execute scrolling
  162.       case @scroll_direction
  163.       when 2  # Down
  164.         scroll_down(distance)
  165.       when 4  # Left
  166.         scroll_left(distance)
  167.       when 6  # Right
  168.         scroll_right(distance)
  169.       when 8  # Up
  170.         scroll_up(distance)
  171.       end
  172.       # Subtract distance scrolled
  173.       @scroll_rest -= distance
  174.     end
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Update Events
  178.   #--------------------------------------------------------------------------
  179.   def update_events
  180.     # Update map event
  181.     for event in @events.values
  182.       event.update
  183.     end
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # * Update Common Events
  187.   #--------------------------------------------------------------------------
  188.   def update_common_events
  189.     # Update common event
  190.     for common_event in @common_events.values
  191.       common_event.update
  192.     end
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Update Fog Scroll
  196.   #--------------------------------------------------------------------------
  197.   def update_fog_scroll
  198.     # Manage fog scrolling
  199.     @fog_ox -= @fog_sx / 8.0
  200.     @fog_oy -= @fog_sy / 8.0
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * Update Fog Color
  204.   #--------------------------------------------------------------------------
  205.   def update_fog_colour
  206.     # Manage change in fog color tone
  207.     if @fog_tone_duration >= 1
  208.       d = @fog_tone_duration
  209.       target = @fog_tone_target
  210.       @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
  211.       @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
  212.       @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
  213.       @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
  214.       @fog_tone_duration -= 1
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Update Fog
  219.   #--------------------------------------------------------------------------
  220.   def update_fog
  221.     # Manage change in fog opacity level
  222.     if @fog_opacity_duration >= 1
  223.       d = @fog_opacity_duration
  224.       @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
  225.       @fog_opacity_duration -= 1
  226.     end
  227.   end
  228. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

5
 楼主| 发表于 2005-12-21 22:10:49 | 显示全部楼层

  1. #==============================================================================
  2. # ** Game_Character
  3. #------------------------------------------------------------------------------
  4. #  This class deals with characters. It's used as a superclass for the
  5. #  Game_Player and Game_Event classes.
  6. #==============================================================================

  7. class Game_Character
  8.   #--------------------------------------------------------------------------
  9.   # * Frame Update
  10.   #--------------------------------------------------------------------------
  11.   def update
  12.     update_movement_type
  13.     update_animation
  14.     update_wait
  15.     return if update_force? == true
  16.     return if update_event_execution? == true
  17.     update_movement
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # * Update Movement Type
  21.   #--------------------------------------------------------------------------
  22.   def update_movement_type
  23.     # Branch with jumping, moving, and stopping
  24.     if jumping?
  25.       update_jump
  26.     elsif moving?
  27.       update_move
  28.     else
  29.       update_stop
  30.     end
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # * Update Animation
  34.   #--------------------------------------------------------------------------
  35.   def update_animation
  36.     # If animation count exceeds maximum value
  37.     # * Maximum value is move speed * 1 taken from basic value 18
  38.     if @anime_count > 18 - @move_speed * 2
  39.       # If stop animation is OFF when stopping
  40.       if not @step_anime and @stop_count > 0
  41.         # Return to original pattern
  42.         @pattern = @original_pattern
  43.       # If stop animation is ON when moving
  44.       else
  45.         # Update pattern
  46.         @pattern = (@pattern + 1) % 4
  47.       end
  48.       # Clear animation count
  49.       @anime_count = 0
  50.     end
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Update Wait
  54.   #--------------------------------------------------------------------------
  55.   def update_wait
  56.     # If waiting
  57.     if @wait_count > 0
  58.       # Reduce wait count
  59.       @wait_count -= 1
  60.       return
  61.     end
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # * Update Force
  65.   #--------------------------------------------------------------------------
  66.   def update_force?
  67.     # If move route is forced
  68.     if @move_route_forcing
  69.       # Custom move
  70.       move_type_custom
  71.       return true
  72.     end
  73.     return false
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Update Event Execution
  77.   #--------------------------------------------------------------------------
  78.   def update_event_execution?
  79.     # When waiting for event execution or locked
  80.     if @starting or lock?
  81.       # Not moving by self
  82.       return true
  83.     end
  84.     return false
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Update Movement
  88.   #--------------------------------------------------------------------------
  89.   def update_movement
  90.     # If stop count exceeds a certain value (computed from move frequency)
  91.     if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  92.       # Branch by move type
  93.       case @move_type
  94.       when 1  # Random
  95.         move_type_random
  96.       when 2  # Approach
  97.         move_type_toward_player
  98.       when 3  # Custom
  99.         move_type_custom
  100.       end
  101.     end
  102.   end
  103. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

6
 楼主| 发表于 2005-12-21 22:11:14 | 显示全部楼层

  1. #==============================================================================
  2. # ** Game_Event
  3. #------------------------------------------------------------------------------
  4. #  This class deals with events. It handles functions including event page
  5. #  switching via condition determinants, and running parallel process events.
  6. #  It's used within the Game_Map class.
  7. #==============================================================================

  8. class Game_Event < Game_Character
  9.   #--------------------------------------------------------------------------
  10.   # * Refresh
  11.   #--------------------------------------------------------------------------
  12.   def refresh
  13.     # Initialize local variable: new_page
  14.     new_page = nil
  15.     # If not temporarily erased
  16.     unless @erased
  17.       new_page = refresh_trigger_conditions
  18.     end
  19.     # If event page is the same as last time
  20.     if new_page == @page
  21.       # End method
  22.       return
  23.     end
  24.     # Set @page as current event page
  25.     @page = new_page
  26.     # Clear starting flag
  27.     clear_starting
  28.     # If no page fulfills conditions
  29.     if @page == nil
  30.       # Reset values
  31.       refresh_reset
  32.       # End method
  33.       return
  34.     end
  35.     # Set page variables
  36.     refresh_set_page
  37.     # Check parallel processing
  38.     refresh_check_process
  39.     # Auto event start determinant
  40.     check_event_trigger_auto
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # * Refresh Trigger Conditions
  44.   #--------------------------------------------------------------------------
  45.   def refresh_trigger_conditions
  46.     # Check in order of large event pages
  47.     for page in @event.pages.reverse
  48.       # Make possible referrence for event condition with c
  49.       c = page.condition
  50.       # Switch 1 condition confirmation
  51.       if c.switch1_valid
  52.         if $game_switches[c.switch1_id] == false
  53.           next
  54.         end
  55.       end
  56.       # Switch 2 condition confirmation
  57.       if c.switch2_valid
  58.         if $game_switches[c.switch2_id] == false
  59.           next
  60.         end
  61.       end
  62.       # Variable condition confirmation
  63.       if c.variable_valid
  64.         if $game_variables[c.variable_id] < c.variable_value
  65.           next
  66.         end
  67.       end
  68.       # Self switch condition confirmation
  69.       if c.self_switch_valid
  70.         key = [@map_id, @event.id, c.self_switch_ch]
  71.         if $game_self_switches[key] != true
  72.           next
  73.         end
  74.       end
  75.       # Set local variable: new_page
  76.       new_page = page
  77.       # Remove loop
  78.       break
  79.     end
  80.     # Return new page
  81.     return new_page
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # * Refresh Reset
  85.   #--------------------------------------------------------------------------
  86.   def refresh_reset
  87.     # Set each instance variable
  88.     @tile_id = 0
  89.     @character_name = ""
  90.     @character_hue = 0
  91.     @move_type = 0
  92.     @through = true
  93.     @trigger = nil
  94.     @list = nil
  95.     @interpreter = nil
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Refresh Set Page
  99.   #--------------------------------------------------------------------------
  100.   def refresh_set_page
  101.     # Set each instance variable
  102.     @tile_id = @page.graphic.tile_id
  103.     @character_name = @page.graphic.character_name
  104.     @character_hue = @page.graphic.character_hue
  105.     if @original_direction != @page.graphic.direction
  106.       @direction = @page.graphic.direction
  107.       @original_direction = @direction
  108.       @prelock_direction = 0
  109.     end
  110.     if @original_pattern != @page.graphic.pattern
  111.       @pattern = @page.graphic.pattern
  112.       @original_pattern = @pattern
  113.     end
  114.     @opacity = @page.graphic.opacity
  115.     @blend_type = @page.graphic.blend_type
  116.     @move_type = @page.move_type
  117.     @move_speed = @page.move_speed
  118.     @move_frequency = @page.move_frequency
  119.     @move_route = @page.move_route
  120.     @move_route_index = 0
  121.     @move_route_forcing = false
  122.     @walk_anime = @page.walk_anime
  123.     @step_anime = @page.step_anime
  124.     @direction_fix = @page.direction_fix
  125.     @through = @page.through
  126.     @always_on_top = @page.always_on_top
  127.     @trigger = @page.trigger
  128.     @list = @page.list
  129.     @interpreter = nil
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # * Refresh Check Process
  133.   #--------------------------------------------------------------------------
  134.   def refresh_check_process
  135.     # If trigger is [parallel process]
  136.     if @trigger == 4
  137.       # Create parallel process interpreter
  138.       @interpreter = Interpreter.new
  139.     end
  140.   end
  141. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

7
 楼主| 发表于 2005-12-21 22:12:06 | 显示全部楼层

  1. #==============================================================================
  2. # ** Game_Player
  3. #------------------------------------------------------------------------------
  4. #  This class handles the player. Its functions include event starting
  5. #  determinants and map scrolling. Refer to "$game_player" for the one
  6. #  instance of this class.
  7. #==============================================================================

  8. class Game_Player < Game_Character
  9.   #--------------------------------------------------------------------------
  10.   # * Frame Update
  11.   #--------------------------------------------------------------------------
  12.   def update
  13.     # Remember whether or not moving in local variables
  14.     last_moving = moving?
  15.     # If moving, event running, move route forcing, and message window
  16.     # display are all not occurring
  17.     unless moving? or $game_system.map_interpreter.running? or
  18.     @move_route_forcing or $game_temp.message_window_showing
  19.       update_player_movement
  20.     end
  21.     # Remember coordinates in local variables
  22.     last_real_x = @real_x
  23.     last_real_y = @real_y
  24.     super
  25.     # Scroll map
  26.     update_scroll_down(last_real_y)
  27.     update_scroll_left(last_real_x)
  28.     update_scroll_right(last_real_x)
  29.     update_scroll_up(last_real_y)
  30.     # If not moving
  31.     unless moving?
  32.       # If player was moving last time
  33.       if last_moving
  34.         update_encounter
  35.       end
  36.       update_action_trigger
  37.     end
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # * Player Movement Update
  41.   #--------------------------------------------------------------------------
  42.   def update_player_movement
  43.     # Move player in the direction the directional button is being pressed
  44.     case Input.dir4
  45.     when 2
  46.       move_down
  47.     when 4
  48.       move_left
  49.     when 6
  50.       move_right
  51.     when 8
  52.       move_up
  53.     end
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # * Scroll Down
  57.   #--------------------------------------------------------------------------
  58.   def update_scroll_down(last_real_y)
  59.     # If character moves down and is positioned lower than the center
  60.     # of the screen
  61.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  62.       # Scroll map down
  63.       $game_map.scroll_down(@real_y - last_real_y)
  64.     end
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * Scroll Left
  68.   #--------------------------------------------------------------------------
  69.   def update_scroll_left(last_real_x)
  70.     # If character moves left and is positioned more let on-screen than
  71.     # center
  72.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  73.       # Scroll map left
  74.       $game_map.scroll_left(last_real_x - @real_x)
  75.     end
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # * Scroll Right
  79.   #--------------------------------------------------------------------------
  80.   def update_scroll_right(last_real_x)
  81.     # If character moves right and is positioned more right on-screen than
  82.     # center
  83.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  84.       # Scroll map right
  85.       $game_map.scroll_right(@real_x - last_real_x)
  86.     end
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # * Scroll Up
  90.   #--------------------------------------------------------------------------
  91.   def update_scroll_up(last_real_y)
  92.     # If character moves up and is positioned higher than the center
  93.     # of the screen
  94.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  95.       # Scroll map up
  96.       $game_map.scroll_up(last_real_y - @real_y)
  97.     end
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # * Update Action Trigger
  101.   #--------------------------------------------------------------------------
  102.   def update_action_trigger
  103.     # If C button was pressed
  104.     if Input.trigger?(Input::C)
  105.       # Same position and front event determinant
  106.       check_event_trigger_here([0])
  107.       check_event_trigger_there([0,1,2])
  108.     end
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Scroll Encounter
  112.   #--------------------------------------------------------------------------
  113.   def update_encounter
  114.     # Event determinant is via touch of same position event
  115.     result = check_event_trigger_here([1,2])
  116.     # If event which started does not exist
  117.     if result == false
  118.       # Disregard if debug mode is ON and ctrl key was pressed
  119.       unless $DEBUG and Input.press?(Input::CTRL)
  120.         # Encounter countdown
  121.         if @encounter_count > 0
  122.           @encounter_count -= 1
  123.         end
  124.       end
  125.     end
  126.   end
  127. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

8
 楼主| 发表于 2005-12-21 22:12:47 | 显示全部楼层

  1. #==============================================================================
  2. # ** Spriteset_Map
  3. #------------------------------------------------------------------------------
  4. #  This class brings together map screen sprites, tilemaps, etc.
  5. #  It's used within the Scene_Map class.
  6. #==============================================================================

  7. class Spriteset_Map
  8.   #--------------------------------------------------------------------------
  9.   # * Object Initialization
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     init_viewports
  13.     init_tilemap
  14.     init_panorama
  15.     init_fog
  16.     init_characters
  17.     init_player
  18.     init_weather
  19.     init_pictures
  20.     init_timer
  21.     # Frame update
  22.     update
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # * Viewport Initialization
  26.   #--------------------------------------------------------------------------
  27.   def init_viewports
  28.     # Make viewports
  29.     @viewport1 = Viewport.new(0, 0, 640, 480)
  30.     @viewport2 = Viewport.new(0, 0, 640, 480)
  31.     @viewport3 = Viewport.new(0, 0, 640, 480)
  32.     @viewport2.z = 200
  33.     @viewport3.z = 5000
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # * Tilemap Initialization
  37.   #--------------------------------------------------------------------------
  38.   def init_tilemap
  39.     # Make tilemap
  40.     @tilemap = Tilemap.new(@viewport1)
  41.     @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  42.     for i in 0..6
  43.       autotile_name = $game_map.autotile_names[i]
  44.       @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  45.     end
  46.     @tilemap.map_data = $game_map.data
  47.     @tilemap.priorities = $game_map.priorities
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # * Panorama Initialization
  51.   #--------------------------------------------------------------------------
  52.   def init_panorama
  53.     # Make panorama plane
  54.     @panorama = Plane.new(@viewport1)
  55.     @panorama.z = -1000
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # * Fog Initialization
  59.   #--------------------------------------------------------------------------
  60.   def init_fog
  61.     # Make fog plane
  62.     @fog = Plane.new(@viewport1)
  63.     @fog.z = 3000
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Character Sprite Initialization
  67.   #--------------------------------------------------------------------------
  68.   def init_characters
  69.     # Make character sprites
  70.     @character_sprites = []
  71.     for i in $game_map.events.keys.sort
  72.       sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
  73.       @character_sprites.push(sprite)
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # * Player Initialization
  78.   #--------------------------------------------------------------------------
  79.   def init_player
  80.     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Weather Initialization
  84.   #--------------------------------------------------------------------------
  85.   def init_weather
  86.     # Make weather
  87.     @weather = RPG::Weather.new(@viewport1)
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Picture Initialization
  91.   #--------------------------------------------------------------------------
  92.   def init_pictures
  93.     # Make picture sprites
  94.     @picture_sprites = []
  95.     for i in 1..50
  96.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  97.         $game_screen.pictures[i]))
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Timer Initialization
  102.   #--------------------------------------------------------------------------
  103.   def init_timer
  104.     # Make timer sprite
  105.     @timer_sprite = Sprite_Timer.new
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Frame Update
  109.   #--------------------------------------------------------------------------
  110.   def update
  111.     update_panorama
  112.     update_fog
  113.     update_tilemap
  114.     update_panorama_plane
  115.     update_fog_plane
  116.     update_character_sprites
  117.     update_weather
  118.     update_picture_sprites
  119.     # Update timer sprite
  120.     @timer_sprite.update
  121.     # Set screen color tone and shake position
  122.     @viewport1.tone = $game_screen.tone
  123.     @viewport1.ox = $game_screen.shake
  124.     # Set screen flash color
  125.     @viewport3.color = $game_screen.flash_color
  126.     # Update viewports
  127.     @viewport1.update
  128.     @viewport3.update
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # * Update Panorama
  132.   #--------------------------------------------------------------------------
  133.   def update_panorama
  134.     # If panorama is different from current one
  135.     if @panorama_name != $game_map.panorama_name or
  136.        @panorama_hue != $game_map.panorama_hue
  137.       @panorama_name = $game_map.panorama_name
  138.       @panorama_hue = $game_map.panorama_hue
  139.       if @panorama.bitmap != nil
  140.         @panorama.bitmap.dispose
  141.         @panorama.bitmap = nil
  142.       end
  143.       if @panorama_name != ""
  144.         @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  145.       end
  146.       Graphics.frame_reset
  147.     end
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Update Fog
  151.   #--------------------------------------------------------------------------
  152.   def update_fog
  153.     # If fog is different than current fog
  154.     if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  155.       @fog_name = $game_map.fog_name
  156.       @fog_hue = $game_map.fog_hue
  157.       if @fog.bitmap != nil
  158.         @fog.bitmap.dispose
  159.         @fog.bitmap = nil
  160.       end
  161.       if @fog_name != ""
  162.         @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  163.       end
  164.       Graphics.frame_reset
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * Update Tilemap
  169.   #--------------------------------------------------------------------------
  170.   def update_tilemap
  171.     # Update tilemap
  172.     @tilemap.ox = $game_map.display_x / 4
  173.     @tilemap.oy = $game_map.display_y / 4
  174.     @tilemap.update
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Update Panorama Plane
  178.   #--------------------------------------------------------------------------
  179.   def update_panorama_plane
  180.     # Update panorama plane
  181.     @panorama.ox = $game_map.display_x / 8
  182.     @panorama.oy = $game_map.display_y / 8
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # * Update Fog Plane
  186.   #--------------------------------------------------------------------------
  187.   def update_fog_plane
  188.     # Update fog plane
  189.     @fog.zoom_x = $game_map.fog_zoom / 100.0
  190.     @fog.zoom_y = $game_map.fog_zoom / 100.0
  191.     @fog.opacity = $game_map.fog_opacity
  192.     @fog.blend_type = $game_map.fog_blend_type
  193.     @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  194.     @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  195.     @fog.tone = $game_map.fog_tone
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # * Update Character Sprites
  199.   #--------------------------------------------------------------------------
  200.   def update_character_sprites
  201.     # Update character sprites
  202.     for sprite in @character_sprites
  203.       sprite.update
  204.     end
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # * Update Weather
  208.   #--------------------------------------------------------------------------
  209.   def update_weather
  210.     # Update weather graphic
  211.     @weather.type = $game_screen.weather_type
  212.     @weather.max = $game_screen.weather_max
  213.     @weather.ox = $game_map.display_x / 4
  214.     @weather.oy = $game_map.display_y / 4
  215.     @weather.update
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Update Picture Sprites
  219.   #--------------------------------------------------------------------------
  220.   def update_picture_sprites
  221.     # Update picture sprites
  222.     for sprite in @picture_sprites
  223.       sprite.update
  224.     end
  225.   end
  226. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

9
 楼主| 发表于 2005-12-21 22:13:29 | 显示全部楼层

  1. #==============================================================================
  2. # ** Scene_Title
  3. #------------------------------------------------------------------------------
  4. #  This class performs title screen processing.
  5. #==============================================================================

  6. class Scene_Title
  7.   #--------------------------------------------------------------------------
  8.   # * Main Processing
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     return if main_battle_test?
  12.     main_database
  13.     main_background
  14.     main_menu
  15.     main_test_continue
  16.     main_audio
  17.     # Execute transition
  18.     Graphics.transition
  19.     # Main loop
  20.     loop do
  21.       main_loop
  22.       break if main_scenechange?
  23.     end
  24.     # Prepare for transition
  25.     Graphics.freeze
  26.     main_dispose
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # * Battle Test Check
  30.   #--------------------------------------------------------------------------
  31.   def main_battle_test?
  32.     # If battle test
  33.     if $BTEST
  34.       battle_test
  35.       return true
  36.     end
  37.     return false
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # * Load Database
  41.   #--------------------------------------------------------------------------
  42.   def main_database
  43.     # Load database
  44.     $data_actors        = load_data("Data/Actors.rxdata")
  45.     $data_classes       = load_data("Data/Classes.rxdata")
  46.     $data_skills        = load_data("Data/Skills.rxdata")
  47.     $data_items         = load_data("Data/Items.rxdata")
  48.     $data_weapons       = load_data("Data/Weapons.rxdata")
  49.     $data_armors        = load_data("Data/Armors.rxdata")
  50.     $data_enemies       = load_data("Data/Enemies.rxdata")
  51.     $data_troops        = load_data("Data/Troops.rxdata")
  52.     $data_states        = load_data("Data/States.rxdata")
  53.     $data_animations    = load_data("Data/Animations.rxdata")
  54.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  55.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  56.     $data_system        = load_data("Data/System.rxdata")
  57.     # Make system object
  58.     $game_system = Game_System.new
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Background Initialization
  62.   #--------------------------------------------------------------------------
  63.   def main_background
  64.     # Make title graphic
  65.     @sprite = Sprite.new
  66.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Main Menu Initialization
  70.   #--------------------------------------------------------------------------
  71.   def main_menu
  72.     # Make command window
  73.     s1 = "New Game"
  74.     s2 = "Continue"
  75.     s3 = "Shutdown"
  76.     @command_window = Window_Command.new(192, [s1, s2, s3])
  77.     @command_window.back_opacity = 160
  78.     @command_window.x = 320 - @command_window.width / 2
  79.     @command_window.y = 288
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Main Test Initialization
  83.   #--------------------------------------------------------------------------
  84.   def main_test_continue
  85.     # Continue enabled determinant
  86.     # Check if at least one save file exists
  87.     # If enabled, make @continue_enabled true; if disabled, make it false
  88.     @continue_enabled = false
  89.     for i in 0..3
  90.       if FileTest.exist?("Save#{i+1}.rxdata")
  91.         @continue_enabled = true
  92.       end
  93.     end
  94.     # If continue is enabled, move cursor to "Continue"
  95.     # If disabled, display "Continue" text in gray
  96.     if @continue_enabled
  97.       @command_window.index = 1
  98.     else
  99.       @command_window.disable_item(1)
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # * Main Audio Initialization
  104.   #--------------------------------------------------------------------------
  105.   def main_audio
  106.     # Play title BGM
  107.     $game_system.bgm_play($data_system.title_bgm)
  108.     # Stop playing ME and BGS
  109.     Audio.me_stop
  110.     Audio.bgs_stop
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Main Loop
  114.   #--------------------------------------------------------------------------
  115.   def main_loop
  116.     # Update game screen
  117.     Graphics.update
  118.     # Update input information
  119.     Input.update
  120.     # Frame update
  121.     update
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Main Scene Scene Change
  125.   #--------------------------------------------------------------------------
  126.   def main_scenechange?
  127.     # Abort loop if screen is changed
  128.     if $scene != self
  129.       return true
  130.     end
  131.     return false
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Main Dispose
  135.   #--------------------------------------------------------------------------
  136.   def main_dispose
  137.     automatic_dispose
  138.   end
  139. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

10
 楼主| 发表于 2005-12-21 22:14:07 | 显示全部楼层

  1. #==============================================================================
  2. # ** Scene_Map
  3. #------------------------------------------------------------------------------
  4. #  This class performs map screen processing.
  5. #==============================================================================

  6. class Scene_Map
  7.   #--------------------------------------------------------------------------
  8.   # * Main Processing
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     main_draw   
  12.     # Main loop
  13.     loop do
  14.       main_loop
  15.       break if main_scenechange?
  16.     end
  17.     main_dispose
  18.     main_tiletrigger
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # * Main Draw
  22.   #--------------------------------------------------------------------------
  23.   def main_draw
  24.     # Make sprite set
  25.     @spriteset = Spriteset_Map.new
  26.     # Make message window
  27.     @message_window = Window_Message.new
  28.     # Transition run
  29.     Graphics.transition
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # * Main Loop
  33.   #--------------------------------------------------------------------------
  34.   def main_loop
  35.     # Update game screen
  36.     Graphics.update
  37.     # Update input information
  38.     Input.update
  39.     # Frame update
  40.     update
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # * Main Scene Change
  44.   #--------------------------------------------------------------------------
  45.   def main_scenechange?
  46.     # Abort loop if screen is changed
  47.     if $scene != self
  48.       return true
  49.     end
  50.     return false
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Main Dispose
  54.   #--------------------------------------------------------------------------
  55.   def main_dispose
  56.     Graphics.freeze
  57.     @spriteset.dispose
  58.     automatic_dispose
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Main Tiletrigger
  62.   #--------------------------------------------------------------------------
  63.   def main_tiletrigger
  64.     # If switching to title screen
  65.     if $scene.is_a?(Scene_Title)
  66.       # Fade out screen
  67.       Graphics.transition
  68.       Graphics.freeze
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Frame Update
  73.   #--------------------------------------------------------------------------
  74.   def update
  75.     # Loop
  76.     loop do
  77.       update_systems
  78.       # Abort loop if player isn't place moving
  79.       unless $game_temp.player_transferring
  80.         break
  81.       end
  82.       # Run place move
  83.       transfer_player
  84.       # Abort loop if transition processing
  85.       if $game_temp.transition_processing
  86.         break
  87.       end
  88.     end
  89.     update_graphics
  90.     return if update_game_over? == true
  91.     return if update_to_title? == true
  92.     # If transition processing
  93.     if $game_temp.transition_processing
  94.       # Clear transition processing flag
  95.       $game_temp.transition_processing = false
  96.       # Execute transition
  97.       if $game_temp.transition_name == ""
  98.         Graphics.transition(20)
  99.       else
  100.         Graphics.transition(40, "Graphics/Transitions/" +
  101.           $game_temp.transition_name)
  102.       end
  103.     end
  104.     # If showing message window
  105.     if $game_temp.message_window_showing
  106.       return
  107.     end
  108.     # If encounter list isn't empty, and encounter count is 0
  109.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  110.       # If event is running or encounter is not forbidden
  111.       unless $game_system.map_interpreter.running? or
  112.              $game_system.encounter_disabled
  113.         # Confirm troop
  114.         n = rand($game_map.encounter_list.size)
  115.         troop_id = $game_map.encounter_list[n]
  116.         # If troop is valid
  117.         if $data_troops[troop_id] != nil
  118.           # Set battle calling flag
  119.           $game_temp.battle_calling = true
  120.           $game_temp.battle_troop_id = troop_id
  121.           $game_temp.battle_can_escape = true
  122.           $game_temp.battle_can_lose = false
  123.           $game_temp.battle_proc = nil
  124.         end
  125.       end
  126.     end
  127.     update_call_menu
  128.     update_call_debug
  129.     # If player is not moving
  130.     unless $game_player.moving?
  131.       update_scene
  132.     end
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Update Systems
  136.   #--------------------------------------------------------------------------
  137.   def update_systems
  138.     # Update map, interpreter, and player order
  139.       # (this update order is important for when conditions are fulfilled
  140.       # to run any event, and the player isn't provided the opportunity to
  141.       # move in an instant)
  142.       $game_map.update
  143.       $game_system.map_interpreter.update
  144.       $game_player.update
  145.       # Update system (timer), screen
  146.       $game_system.update
  147.       $game_screen.update
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Update Graphics
  151.   #--------------------------------------------------------------------------
  152.   def update_graphics
  153.     # Update sprite set
  154.     @spriteset.update
  155.     # Update message window
  156.     @message_window.update
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Update Game Over
  160.   #--------------------------------------------------------------------------
  161.   def update_game_over?
  162.      # If game over
  163.     if $game_temp.gameover
  164.       # Switch to game over screen
  165.       $scene = Scene_Gameover.new
  166.       return true
  167.     end
  168.     return false
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Update To Title
  172.   #--------------------------------------------------------------------------
  173.   def update_to_title?
  174.     # If returning to title screen
  175.     if $game_temp.to_title
  176.       # Change to title screen
  177.       $scene = Scene_Title.new
  178.       return true
  179.     end
  180.     return false
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Update Menu Call
  184.   #--------------------------------------------------------------------------
  185.   def update_call_menu
  186.     # If B button was pressed
  187.     if Input.trigger?(Input::B)
  188.       # If event is running, or menu is not forbidden
  189.       unless $game_system.map_interpreter.running? or
  190.              $game_system.menu_disabled
  191.         # Set menu calling flag or beep flag
  192.         $game_temp.menu_calling = true
  193.         $game_temp.menu_beep = true
  194.       end
  195.     end
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # * Update Debug Call
  199.   #--------------------------------------------------------------------------
  200.   def update_call_debug
  201.     # If debug mode is ON and F9 key was pressed
  202.     if $DEBUG and Input.press?(Input::F9)
  203.       # Set debug calling flag
  204.       $game_temp.debug_calling = true
  205.     end
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # * Update Scene
  209.   #--------------------------------------------------------------------------
  210.   def update_scene
  211.     # Run calling of each screen
  212.     if $game_temp.battle_calling
  213.        call_battle
  214.      elsif $game_temp.shop_calling
  215.        call_shop
  216.      elsif $game_temp.name_calling
  217.        call_name
  218.      elsif $game_temp.menu_calling
  219.        call_menu
  220.      elsif $game_temp.save_calling
  221.        call_save
  222.      elsif $game_temp.debug_calling
  223.        call_debug
  224.      end
  225.   end
  226. end

复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-6-2 22:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表