The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: Nathmatt on May 13, 2010, 12:55:16 PM

Title: [VX] Scene_Base
Post by: Nathmatt on May 13, 2010, 12:55:16 PM
Scene_Base
Authors: Nathmatt
Version: 1.02

Introduction
This script is an updated version of the original Scene_Base

Features


Screenshots

no screenshot

Demo
no demo

Script

Spoiler for:
Code: [Select]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Scene_Base by Nathmatt
# Version: 1.01
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  This is a superclass of all scenes in the game.
#==============================================================================

class Scene_Base
  attr_accessor :windows
  attr_accessor :sprites
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    add_processing                # Adds processing
    start                         # Start processing
    perform_transition            # Perform transition
    post_start                    # Post-start processing
    Input.update                  # Update input information
    loop do
      Graphics.update             # Update game screen
      Input.update                # Update input information
      update                      # Update frame
      update_windows              # update windows
      break if $scene != self     # When screen is switched, interrupt loop
    end
    Graphics.update
    pre_terminate                 # Pre-termination processing
    Graphics.freeze               # Prepare transition
    terminate                     # Termination processing
    terminate_windows             # terminate windows
  end
  #--------------------------------------------------------------------------
  # * Add processing
  #--------------------------------------------------------------------------
  def add_processing
    @windows = []
    @sprites  = []
    @animate = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update_windows
    @windows.each{|s| s.update if !s.updated? && s.active}
  end
  #--------------------------------------------------------------------------
  # * Terminate Windows Processing
  #--------------------------------------------------------------------------
  def terminate_windows
    @windows.each{|s| s.dispose if !s.disposed?}
    @sprites.each{|s| s.dispose if !s.disposed?}
  end
 
end
#==============================================================================
# Window
#==============================================================================
class Window
 
  alias scene_base_initialize initialize unless $@
  def initialize(viewport = nil)
    scene_base_initialize(viewport = nil)
    self.openness = 0
    $scene.windows.push(self)
  end
  alias scene_base_update update unless $@
  def update
    @frame_count = Graphics.frame_count if @frame_count != Graphics.frame_count
    scene_base_update
  end
 
  def updated?
    return true if @frame_count == Graphics.frame_count
  end
 
end
#==============================================================================
# Sprite
#==============================================================================
class Sprite
 
  alias scene_base_initialize initialize unless $@
  def initialize(viewport = nil)
    scene_base_initialize(viewport = nil)
    $scene.sprites.push(self)
  end
 
end

Instructions
just place above main

Compatibility
Should not have any compatibility issues

Credits and Thanks


Author's Notes

If you have any suggestions post here
Title: Re: [VX] Scene_Base
Post by: Deity on May 13, 2010, 01:10:52 PM
Wow a nice idea!
But i don't know if it's helpfull. I think you'll update unneeded things like Windows which aren't active and this can cause laggs.
Anyways I think it's a good idea. xD

Deity
Title: Re: [VX] Scene_Base
Post by: modern algebra on May 13, 2010, 01:14:01 PM
Well, it's not a bad idea, I guess. But I'm not sure how much it will be used since most people writing a script would rather just dispose the windows manually than require the user to install a whole other script. However, it's nice if you have a series of scripts that you'll release as a compilation. One thing I'll mention is that you don't need to recopy the entire class, only the parts you want to change, so you can make the script quite a bit smaller than it is.

Also, you'll probably want to add an
Code: [Select]
unless $@
after the aliases in Window and Sprite, as you will get an F12 error otherwise.
Title: Re: [VX] Scene_Base
Post by: Nathmatt on May 13, 2010, 01:31:48 PM
i made it as more of a use it with the custom scripts you make for yourself and made sure it only updates windows 1nce per frame so if they have been updated they wont update again
fixed the only updates active windows and the unless $@