Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Title_Sunbeam
- #------------------------------------------------------------------------------
- # This class performs the sunbeam processing for the title screen.
- #==============================================================================
- class Title_Sunbeam
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(index)
- # Set management variables
- @frame_duration = rand(120)
- @opacity = rand(30) + 20
- @opacity_target = rand(30) + 10
- @opacity_target_target = rand(50) + 10
- # Load the bitmap
- image = Bitmap.new("Graphics/System/Sunbeam_" + index.to_s)
- # Set up the sprite
- @image = Sprite.new()
- @image.bitmap = image
- @image.visible = true
- @image.x = 0
- @image.y = 0
- @image.z = 1
- @image.opacity = @opacity
- end
- #--------------------------------------------------------------------------
- # * Free
- #--------------------------------------------------------------------------
- def dispose
- # Dispose of the bitmap
- @image.bitmap.dispose() if !@image.bitmap.disposed?()
- # Dispose of the sprite
- @image.dispose() if !@image.disposed?()
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # If the frame count has run out
- if (@frame_duration <= 0)
- # Set the new target opacity and timing, then return
- @frame_duration = 50
- @opacity_target_target = rand(125) + rand(25) + 10
- return
- end
- # Update the image opacity target
- d = @frame_duration
- @opacity_target = (@opacity_target * (d - 1) + @opacity_target_target) / d
- # Decrement the frame duration
- @frame_duration -= 1
- # Update the image opacity
- d = 30
- @opacity = (@opacity * (d - 1) + @opacity_target) / d
- @image.opacity = @opacity
- end
- end
- #==============================================================================
- # ** Title_Dot
- #------------------------------------------------------------------------------
- # This class performs the dot processing for the title screen.
- #==============================================================================
- class Title_Dot
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- # Set management variables
- @x_target_duration = rand(120)
- @x_target_target = (rand(624) - 40)
- @y_target_duration = rand(120)
- @y_target_target = (rand(496) - 40)
- @x = (rand(624) - 40)
- @x_target = (rand(624) - 40)
- @y = (rand(496) - 40)
- @y_target = (rand(496) - 40)
- @opacity_target_duration = rand(120)
- @opacity_target_target = (rand(200) + 20)
- @opacity = (rand(150) + 20)
- @opacity_target = (rand(150) + 20)
- @zoom_target_duration = rand(120).to_f
- @zoom_target_target = (rand(99).to_f + 1.0) / 100.0
- @zoom = (rand(99).to_f + 1.0) / 100.0
- @zoom_target = (rand(99).to_f + 1.0) / 100.0
- # Load the bitmap
- image = Bitmap.new("Graphics/System/Glowy_Dot")
- # Set up the sprite
- @image = Sprite.new()
- @image.bitmap = image
- @image.visible = true
- @image.x = @x
- @image.y = @y
- @image.z = 30
- @image.opacity = @opacity
- @image.zoom_x = @zoom
- @image.zoom_y = @zoom
- end
- #--------------------------------------------------------------------------
- # * Free
- #--------------------------------------------------------------------------
- def dispose
- # Dispose of the bitmap
- @image.bitmap.dispose() if !@image.bitmap.disposed?()
- # Dispose of the sprite
- @image.dispose() if !@image.disposed?()
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- update_opacity_target()
- update_zoom_target()
- update_x_target()
- update_y_target()
- update_opacity()
- update_zoom()
- update_x()
- update_y()
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Opacity Target)
- #--------------------------------------------------------------------------
- def update_opacity_target
- # If the frame count has run out
- if (@opacity_target_duration <= 0)
- # Set the new target opacity and timing, then return
- @opacity_target_duration = 120
- @opacity_target_target = (rand(200) + 20)
- return
- end
- # Update the image opacity target
- d = @opacity_target_duration
- @opacity_target = (@opacity_target * (d - 1) + @opacity_target_target) / d
- # Decrement the frame duration
- @opacity_target_duration -= 1
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Opacity)
- #--------------------------------------------------------------------------
- def update_opacity
- # Update the image opacity
- d = 120
- @opacity = (@opacity * (d - 1) + @opacity_target) / d
- @image.opacity = @opacity
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Zoom Target)
- #--------------------------------------------------------------------------
- def update_zoom_target
- # If the frame count has run out
- if (@zoom_target_duration <= 0)
- # Set the new target zoom and timing, then return
- @zoom_target_duration = 120.0
- @zoom_target_target = (rand(99).to_f + 1.0) / 100.0
- return
- end
- # Update the image zoom target
- d = @zoom_target_duration
- @zoom_target = (@zoom_target * (d - 1.0) + @zoom_target_target) / d
- # Decrement the frame duration
- @zoom_target_duration -= 1
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Zoom)
- #--------------------------------------------------------------------------
- def update_zoom
- # Update the image zoom
- d = 120.0
- @zoom = (@zoom * (d - 1.0) + @zoom_target) / d
- @image.zoom_x = @zoom
- @image.zoom_y = @zoom
- end
- #--------------------------------------------------------------------------
- # * Frame Update (X Target)
- #--------------------------------------------------------------------------
- def update_x_target
- # If the frame count has run out
- if (@x_target_duration <= 0)
- # Set the new target x and timing, then return
- @x_target_duration = 120
- @x_target_target = (rand(624) - 40)
- return
- end
- # Update the image x target
- d = @x_target_duration
- @x_target = (@x_target * (d - 1.0) + @x_target_target) / d
- # Decrement the frame duration
- @x_target_duration -= 1
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Y Target)
- #--------------------------------------------------------------------------
- def update_y_target
- # If the frame count has run out
- if (@y_target_duration <= 0)
- # Set the new target y and timing, then return
- @y_target_duration = 120
- @y_target_target = (rand(496) - 40)
- return
- end
- # Update the image y target
- d = @y_target_duration
- @y_target = (@y_target * (d - 1.0) + @y_target_target) / d
- # Decrement the frame duration
- @y_target_duration -= 1
- end
- #--------------------------------------------------------------------------
- # * Frame Update (X Position)
- #--------------------------------------------------------------------------
- def update_x
- # Update the image x
- d = 120
- @x = (@x * (d - 1.0) + @x_target) / d
- @image.x = @x
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Y Position)
- #--------------------------------------------------------------------------
- def update_y
- # Update the image y
- d = 120
- @y = (@y * (d - 1.0) + @y_target) / d
- @image.y = @y
- end
- end
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # This class performs the title screen processing.
- #==============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- SceneManager.clear
- Graphics.freeze
- create_background
- create_foreground
- create_sunbeams
- create_dots
- create_command_window
- play_title_music
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # Call the parent method
- super
- # Iterate through the list of sunbeams
- for sunbeam in @sunbeams
- # Update the sunbeam
- sunbeam.update()
- end
- # Iterate through the list of dots
- for dot in @dots
- # Update the dot
- dot.update()
- end
- end
- #--------------------------------------------------------------------------
- # * Get Transition Speed
- #--------------------------------------------------------------------------
- def transition_speed
- return 20
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- SceneManager.snapshot_for_background
- dispose_background
- dispose_foreground
- dispose_sunbeams
- dispose_dots
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- @sprite1 = Sprite.new
- @sprite1.bitmap = Cache.title1($data_system.title1_name)
- @sprite2 = Sprite.new
- @sprite2.bitmap = Cache.title2($data_system.title2_name)
- @sprite2.z = 50
- center_sprite(@sprite1)
- center_sprite(@sprite2)
- end
- #--------------------------------------------------------------------------
- # * Create Foreground
- #--------------------------------------------------------------------------
- def create_foreground
- @foreground_sprite = Sprite.new
- @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- @foreground_sprite.z = 100
- draw_game_title if $data_system.opt_draw_title
- end
- #--------------------------------------------------------------------------
- # * Create Sunbeams
- #--------------------------------------------------------------------------
- def create_sunbeams
- # Initialize the sunbeam array
- @sunbeams = []
- # Iterate through the list of sunbeams
- for i in 0...5
- # Create the sunbeam graphic and add it to the array
- @sunbeams.push(Title_Sunbeam.new(i + 1))
- end
- end
- #--------------------------------------------------------------------------
- # * Create Dots
- #--------------------------------------------------------------------------
- def create_dots
- # Initialize the dot array
- @dots = []
- # Iterate through the list of sunbeams
- for i in 0...100
- # Create the sunbeam graphic and add it to the array
- @dots.push(Title_Dot.new())
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Game Title
- #--------------------------------------------------------------------------
- def draw_game_title
- @foreground_sprite.bitmap.font.size = 48
- rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)
- @foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1)
- end
- #--------------------------------------------------------------------------
- # * Free Background
- #--------------------------------------------------------------------------
- def dispose_background
- @sprite1.bitmap.dispose
- @sprite1.dispose
- @sprite2.bitmap.dispose
- @sprite2.dispose
- end
- #--------------------------------------------------------------------------
- # * Free Foreground
- #--------------------------------------------------------------------------
- def dispose_foreground
- @foreground_sprite.bitmap.dispose
- @foreground_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # * Free Sunbeams
- #--------------------------------------------------------------------------
- def dispose_sunbeams
- # Iterate through the list of sunbeams
- for sunbeam in @sunbeams
- # Dispose of the sunbeam
- sunbeam.dispose
- end
- # Clear the list of sunbeams
- @sunbeams.clear
- end
- #--------------------------------------------------------------------------
- # * Free Dots
- #--------------------------------------------------------------------------
- def dispose_dots
- # Iterate through the list of sunbeams
- for dot in @dots
- # Dispose of the sunbeam
- dot.dispose
- end
- # Clear the list of sunbeams
- @dots.clear
- end
- #--------------------------------------------------------------------------
- # * Move Sprite to Screen Center
- #--------------------------------------------------------------------------
- def center_sprite(sprite)
- sprite.ox = sprite.bitmap.width / 2
- sprite.oy = sprite.bitmap.height / 2
- sprite.x = Graphics.width / 2
- sprite.y = Graphics.height / 2
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- def create_command_window
- @command_window = Window_TitleCommand.new
- @command_window.set_handler(:new_game, method(:command_new_game))
- @command_window.set_handler(:continue, method(:command_continue))
- @command_window.set_handler(:shutdown, method(:command_shutdown))
- end
- #--------------------------------------------------------------------------
- # * Close Command Window
- #--------------------------------------------------------------------------
- def close_command_window
- @command_window.close
- update until @command_window.close?
- end
- #--------------------------------------------------------------------------
- # * [New Game] Command
- #--------------------------------------------------------------------------
- def command_new_game
- DataManager.setup_new_game
- close_command_window
- fadeout_all
- $game_map.autoplay
- SceneManager.goto(Scene_Map)
- end
- #--------------------------------------------------------------------------
- # * [Continue] Command
- #--------------------------------------------------------------------------
- def command_continue
- close_command_window
- SceneManager.call(Scene_Load)
- end
- #--------------------------------------------------------------------------
- # * [Shut Down] Command
- #--------------------------------------------------------------------------
- def command_shutdown
- close_command_window
- fadeout_all
- SceneManager.exit
- end
- #--------------------------------------------------------------------------
- # * Play Title Screen Music
- #--------------------------------------------------------------------------
- def play_title_music
- $data_system.title_bgm.play
- RPG::BGS.stop
- RPG::ME.stop
- end
- end
RAW Paste Data