#==============================================================================
# +++ MOG - Rin Title Screen (v1.0) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Tela de título animada com o tema da Rin Kaenbyou, para os fans de Touhou.
# Naturalmente é possível customizar qualquer tipo de personagem.
#==============================================================================
module MOG_RIN_TITLE_SCRREN
#Definição da velocidade de deslize da imagem de fundo.
BACKGROUND_SCROLL_SPEED = [1,0]
#Definição da quantidade de partículas.
NUMBER_OF_PARTICLES = 20
#Definição do tipo de blend da partícula.
PARTICLES_BLEND_TYPE = 1
#Definição da força do efeito wave na névoa.
FIRE_WIND_POWER = 10
#Definição da velocidade do efeito wave na névoa.
FIRE_WIND_SPEED = 1
#Tipo de Blend.
FIRE_BLEND_TYPE = 0
#Definição da opacidade da névoa.
FIRE_OPACITY = 255
#Definição da posição do personagem.
CHARACTER_POSITION = [0,0]
#Definição da posição do comando.
COMMAND_POSITION = [0,5]
#Ativar efeito aura na imagem do personagem.
CHARACTER_AURA_EFFECT = true
#Ativar Logo.
LOGO = true
#Definição da duração do logo.
LOGO_DURATION = 2
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
include MOG_RIN_TITLE_SCRREN
#--------------------------------------------------------------------------
# ● Main
#--------------------------------------------------------------------------
def main
execute_logo if LOGO
Graphics.update
Graphics.freeze
execute_setup
execute_loop
dispose
end
#--------------------------------------------------------------------------
# ● Execute Setup
#--------------------------------------------------------------------------
def execute_setup
@phase = 0
@active = false
@continue_enabled = DataManager.save_file_exists?
@com_index = @continue_enabled ? 1 : 0
@com_index_old = @com_index
@com_index_max = 2
create_sprites
end
#--------------------------------------------------------------------------
# ● Execute Lopp
#--------------------------------------------------------------------------
def execute_loop
Graphics.transition(60)
play_title_music
loop do
Input.update
update
Graphics.update
break if SceneManager.scene != self
end
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
include MOG_RIN_TITLE_SCRREN
#--------------------------------------------------------------------------
# ● Execute Logo
#--------------------------------------------------------------------------
def execute_logo
Graphics.transition
create_logo
loop do
Input.update
update_logo
Graphics.update
break if !@logo_phase
end
dispose_logo
end
#--------------------------------------------------------------------------
# ● Create Logo
#--------------------------------------------------------------------------
def create_logo
@logo = Sprite.new
@logo.z = 100
@logo.opacity = 0
@logo_duration = [0,60 * LOGO_DURATION]
@logo.bitmap = Cache.title1("Logo") rescue nil
@logo_phase = @logo.bitmap != nil ? true : false
end
#--------------------------------------------------------------------------
# ● Dispose Logo
#--------------------------------------------------------------------------
def dispose_logo
Graphics.freeze
@logo.bitmap.dispose if @logo.bitmap != nil
@logo.dispose
end
#--------------------------------------------------------------------------
# ● Update Logo
#--------------------------------------------------------------------------
def update_logo
return if !@logo_phase
update_logo_command
if @logo_duration[0] == 0
@logo.opacity += 5
@logo_duration[0] = 1 if @logo.opacity >= 255
elsif @logo_duration[0] == 1
@logo_duration[1] -= 1
@logo_duration[0] = 2 if @logo_duration[1] <= 0
else
@logo.opacity -= 5
@logo_phase = false if @logo.opacity <= 0
end
end
#--------------------------------------------------------------------------
# ● Update Logo Command
#--------------------------------------------------------------------------
def update_logo_command
return if @logo_duration[0] == 2
if Input.trigger?(:C) or Input.trigger?(:B)
@logo_duration = [2,0]
end
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● Create Sprites
#--------------------------------------------------------------------------
def create_sprites
create_background
create_fire_wind
create_commands
create_particles
create_character
create_layout
create_skulls
end
#--------------------------------------------------------------------------
# ● Create Background
#--------------------------------------------------------------------------
def create_background
@background = Plane.new
@background.bitmap = Cache.title1("Background")
@background_scroll = [BACKGROUND_SCROLL_SPEED[0],BACKGROUND_SCROLL_SPEED[1],0]
@background.z = 0
end
#--------------------------------------------------------------------------
# ● Create Layout
#--------------------------------------------------------------------------
def create_layout
@layout = Sprite.new
@layout.bitmap = Cache.title1("Layout")
@layout.z = 20
@layout.opacity = 0
end
#--------------------------------------------------------------------------
# ● Create Commands
#--------------------------------------------------------------------------
def create_commands
@com = []
for index in 0...3
@com.push(Title_Commands.new(nil,index))
end
end
#--------------------------------------------------------------------------
# ● Create Skulls
#--------------------------------------------------------------------------
def create_skulls
@skulls = []
for index in 0...3
@skulls.push(Title_Skull.new(nil,index))
end
end
#--------------------------------------------------------------------------
# ● Create Fire Wind
#--------------------------------------------------------------------------
def create_fire_wind
@fire_wind = []
@fire_wind_image = Cache.title1("Fire_Wind")
fire_max = 1
for index in 0...fire_max
range = (FIRE_WIND_POWER + 1 + (index * 2)) * 10
range = 500 if range > 500
speed = (FIRE_WIND_SPEED + 1 + (index * 2)) * 100
speed = 1000 if speed > 1000
@fire_wind.push(Sprite.new)
@fire_wind[index].wave_amp = range
@fire_wind[index].wave_length = Graphics.width
@fire_wind[index].wave_speed = speed
@fire_wind[index].bitmap = Bitmap.new(Graphics.width + (range * 2),Graphics.height)
@fire_wind[index].bitmap.stretch_blt(@fire_wind[index].bitmap.rect, @fire_wind_image, @fire_wind_image.rect)
@fire_wind[index].x = -range
@fire_wind[index].z = 6
@fire_wind[index].blend_type = FIRE_BLEND_TYPE
@fire_wind[index].opacity = FIRE_OPACITY + (40 * index)
end
end
#--------------------------------------------------------------------------
# ● Create Particles
#--------------------------------------------------------------------------
def create_particles
@particles_sprite =[]
for i in 0...NUMBER_OF_PARTICLES
@particles_sprite.push(Particles_Title.new(nil))
end
end
#--------------------------------------------------------------------------
# ● Create Character
#--------------------------------------------------------------------------
def create_character
@character = Sprite.new
@character.bitmap = Cache.title1("Character")
@character.ox = @character.bitmap.width / 2
@character.oy = @character.bitmap.height / 2
@character.x = CHARACTER_POSITION[0] + @character.ox
@character.y = CHARACTER_POSITION[1] + @character.oy
@character.z = 3
@character.opacity = 0
@char_zoom_speed = [0,0]
@character2 = Sprite.new
@character2.bitmap = Cache.title1("Character")
@character2.ox = @character.bitmap.width / 2
@character2.oy = @character.bitmap.height / 2
@character2.x = CHARACTER_POSITION[0] + @character.ox
@character2.y = CHARACTER_POSITION[1] + @character.oy
@character2.z = 2
@character2.blend_type = 0
@character2.opacity = 0
@character2.visible = CHARACTER_AURA_EFFECT
end
end
#==============================================================================
# ■ Particles Title
#==============================================================================
class Particles_Title < Sprite
include MOG_RIN_TITLE_SCRREN
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
@speed_x = 0
@speed_y = 0
@speed_a = 0
self.bitmap = Cache.title1("Particles")
self.blend_type = PARTICLES_BLEND_TYPE
self.z = 4
reset_setting(true)
end
#--------------------------------------------------------------------------
# ● Reset Setting
#--------------------------------------------------------------------------
def reset_setting(initial = false)
zoom = (50 + rand(100)) / 100.1
self.zoom_x = zoom
self.zoom_y = zoom
self.x = rand(576) - 160
self.y = initial == true ? rand(480) : 512
self.opacity = 0
@speed_y = -(1 + rand(3))
@speed_x = (1 + rand(2))
@speed_a = (1 + rand(2))
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
super
self.bitmap.dispose if self.bitmap != nil
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
self.x += @speed_x
self.y += @speed_y
# self.angle += @speed_a
self.opacity += 5
reset_setting if can_reset_setting?
end
#--------------------------------------------------------------------------
# ● Can Reset Setting
#--------------------------------------------------------------------------
def can_reset_setting?
return true if self.y < -50
return true if self.x > 576
return false
end
end
#==============================================================================
# ■ Title Commands
#==============================================================================
class Title_Commands < Sprite
include MOG_RIN_TITLE_SCRREN
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil,index)
super(viewport)
@index = index
@float = [0,0,0]
self.bitmap = Cache.title1("Command" + index.to_s)
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
@org_pos = [COMMAND_POSITION[0] + self.ox,
COMMAND_POSITION[1] + self.oy + (self.bitmap.height + 2) * index,
self.ox - 24]
self.x = @org_pos[0] - self.bitmap.width - (self.bitmap.width * index)
self.y = @org_pos[1]
self.z = 25
@next_pos = [@org_pos[0],@org_pos[1]]
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose_sprites
self.bitmap.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_sprites(index,active)
# return if !active
if index == @index
self.opacity += 10
@next_pos[0] = @org_pos[0]
# update_float_effect
else
self.opacity -= 10 if self.opacity > 120
@next_pos[0] = @org_pos[2]
@float = [0,0,0]
end
update_slide(0,@next_pos[0])
update_slide(1,@org_pos[1] + @float[0])
end
#--------------------------------------------------------------------------
# ● Update Slide
#--------------------------------------------------------------------------
def update_slide(type,np)
cp = type == 0 ? self.x : self.y
sp = 3 + ((cp - np).abs / 10)
if cp > np
cp -= sp
cp = np if cp < np
elsif cp < np
cp += sp
cp = np if cp > np
end
self.x = cp if type == 0
self.y = cp if type == 1
end
#--------------------------------------------------------------------------
# ● Update Float Effect
#--------------------------------------------------------------------------
def update_float_effect
@float[2] += 1
return if @float[2] < 5
@float[2] = 0
@float[1] += 1
case @float[1]
when 1..5
@float[0] -= 1
when 6..15
@float[0] += 1
when 16..20
@float[0] -= 1
else
@float[0] = 0
@float[1] = 0
end
end
end
#==============================================================================
# ■ Title Skull
#==============================================================================
class Title_Skull < Sprite
include MOG_RIN_TITLE_SCRREN
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil,index)
super(viewport)
@index = index
@float = [0,0,0]
@move_phase = @index
self.bitmap = Cache.title1("Skull")
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
@org_pos = [Graphics.width + self.ox, 150 + self.oy,
-self.ox]
self.x = @index == 0 ? @org_pos[0] : @org_pos[2]
self.y = @org_pos[1]
self.z = 15
self.blend_type = 0
@next_pos = [@org_pos[0],@org_pos[1]]
z1 = Graphics.width / 3
z2 = z1 * 2
@zoom_phase = [0,z2,@org_pos[0]]
@fade_phase = 0
setup_move
if @index == 2
@org_pos[0] = 150
@org_pos[1] = 200
self.x = @org_pos[0]
self.y = @org_pos[1]
self.mirror = false
self.zoom_x = 1.00
self.zoom_y = 1.00
self.angle = 30
self.z = 15
end
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose_sprites
self.bitmap.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update_sprites(active)
# return if !active
update_float_effect
update_move unless @index == 2
update_slide(1,@org_pos[1] + @float[0])
end
#--------------------------------------------------------------------------
# ● Setup Move
#--------------------------------------------------------------------------
def setup_move
# self.opacity = 100 + rand(155)
# @fade_phase = 0
if @move_phase == 0
@move_phase = 1
self.x = @org_pos[2]
self.mirror = true
self.z = 15
self.zoom_x = 0.50
self.zoom_y = 0.50
@org_pos[1] = 100 + self.oy + rand(100)
else
@move_phase = 0
self.x = @org_pos[0]
self.mirror = false
self.z = 2
self.zoom_x = 1.00
self.zoom_y = 1.00
@org_pos[1] = -50 + self.oy + rand(100)
end
end
#--------------------------------------------------------------------------
# ● Update Move
#--------------------------------------------------------------------------
def update_move
if @move_phase == 0
self.x -= 1
if self.x.between?(@zoom_phase[1],@zoom_phase[2])
self.zoom_x -= 0.001
self.zoom_x = 0.50 if self.zoom_x < 0.50
else
self.zoom_x += 0.001
self.zoom_x = 1.00 if self.zoom_x > 1.00
end
setup_move if self.x <= @org_pos[2]
else
self.x += 1
if self.x.between?(@zoom_phase[0],@zoom_phase[1])
self.zoom_x += 0.001
self.zoom_x = 1.00 if self.zoom_x > 1.00
else
self.zoom_x -= 0.001
self.zoom_x = 0.50 if self.zoom_x < 0.50
end
setup_move if self.x >= @org_pos[0]
end
self.zoom_y = self.zoom_x
# update_fade
end
#--------------------------------------------------------------------------
# ● Update Fade
#--------------------------------------------------------------------------
def update_fade
if @fade_phase == 0
self.opacity -= 5
@fade_phase = 1 if self.opacity == 0
else
self.opacity += 5
@fade_phase = 0 if self.opacity == 255
end
end
#--------------------------------------------------------------------------
# ● Update Slide
#--------------------------------------------------------------------------
def update_slide(type,np)
cp = type == 0 ? self.x : self.y
sp = 3 + ((cp - np).abs / 10)
if cp > np
cp -= sp
cp = np if cp < np
elsif cp < np
cp += sp
cp = np if cp > np
end
self.x = cp if type == 0
self.y = cp if type == 1
end
#--------------------------------------------------------------------------
# ● Update Float Effect
#--------------------------------------------------------------------------
def update_float_effect
@float[2] += 1
return if @float[2] < 4
@float[2] = 0
@float[1] += 1
case @float[1]
when 1..5
@float[0] -= 1
when 6..15
@float[0] += 1
when 16..20
@float[0] -= 1
else
@float[0] = 0
@float[1] = 0
end
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
Graphics.freeze
dispose_background
dispose_fire_wind
dispose_particles
dispose_character
dispose_layout
dispose_commands
dispose_skulls
end
#--------------------------------------------------------------------------
# ● Dispose Background
#--------------------------------------------------------------------------
def dispose_background
@background.bitmap.dispose
@background.dispose
end
#--------------------------------------------------------------------------
# ● Dispose Layout
#--------------------------------------------------------------------------
def dispose_layout
@layout.bitmap.dispose
@layout.dispose
end
#--------------------------------------------------------------------------
# ● Dispose Commands
#--------------------------------------------------------------------------
def dispose_commands
@com.each {|sprite| sprite.dispose_sprites }
end
#--------------------------------------------------------------------------
# ● Dispose Skulls
#--------------------------------------------------------------------------
def dispose_skulls
@skulls.each {|sprite| sprite.dispose_sprites }
end
#--------------------------------------------------------------------------
# ● Dispose Fire Wind
#--------------------------------------------------------------------------
def dispose_fire_wind
@fire_wind.each {|sprite| sprite.bitmap.dispose }
@fire_wind.each {|sprite| sprite.dispose }
@fire_wind_image.dispose
end
#--------------------------------------------------------------------------
# ● Dispose Particles
#--------------------------------------------------------------------------
def dispose_particles
@particles_sprite.each {|sprite| sprite.dispose }
end
#--------------------------------------------------------------------------
# ● Dispose Character
#--------------------------------------------------------------------------
def dispose_character
@character.bitmap.dispose
@character.dispose
@character2.bitmap.dispose
@character2.dispose
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● Update Sprites
#--------------------------------------------------------------------------
def update_sprites
update_background
update_fire_wind
update_particles
update_character
update_commands
update_skulls
end
#--------------------------------------------------------------------------
# ● Update Background
#--------------------------------------------------------------------------
def update_background
@layout.opacity += 5
@background_scroll[2] += 1
return if @background_scroll[2] < 4
@background_scroll[2] = 0
@background.ox += @background_scroll[0]
@background.oy += @background_scroll[1]
end
#--------------------------------------------------------------------------
# ● Update Commands
#--------------------------------------------------------------------------
def update_commands
@com.each {|sprite| sprite.update_sprites(@com_index,@active)}
end
#--------------------------------------------------------------------------
# ● Update Skulls
#--------------------------------------------------------------------------
def update_skulls
@skulls.each {|sprite| sprite.update_sprites(@active)}
end
#--------------------------------------------------------------------------
# ● Update Fire Wind
#--------------------------------------------------------------------------
def update_fire_wind
@fire_wind.each {|sprite| sprite.update }
end
#--------------------------------------------------------------------------
# ● Update Particles
#--------------------------------------------------------------------------
def update_particles
@particles_sprite.each {|sprite| sprite.update }
end
#--------------------------------------------------------------------------
# ● Update Character
#--------------------------------------------------------------------------
def update_character
@character.opacity += 5
return if !@character2.visible
if @char_zoom_speed[1] > 0
@char_zoom_speed[1] -= 1
@character2.opacity = 0
@character2.opacity = 255 if @char_zoom_speed[1] == 0
end
return if @char_zoom_speed[1] > 0
@char_zoom_speed[0] += 1
return if @char_zoom_speed[0] < 5
@char_zoom_speed[0] = 0
@character2.zoom_x += 0.01
@character2.opacity -= 5
if @character2.opacity <= 0
@character2.zoom_x = 1.00
@character2.opacity = 0
@char_zoom_speed[1] = 120
end
@character2.zoom_y = @character2.zoom_x
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
update_command
update_sprites
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● Update Command
#--------------------------------------------------------------------------
def update_command
update_key
refresh_index if @com_index_old != @com_index
end
#--------------------------------------------------------------------------
# ● Update Key
#--------------------------------------------------------------------------
def update_key
if Input.trigger?(:DOWN)
add_index(1)
elsif Input.trigger?(:UP)
add_index(-1)
elsif Input.trigger?(:C)
select_command
end
end
#--------------------------------------------------------------------------
# ● Select Command
#--------------------------------------------------------------------------
def select_command
# if !@active
# @active = true
# return
# end
case @com_index
when 0; command_new_game
when 1; command_continue
when 2; command_shutdown
end
end
#--------------------------------------------------------------------------
# ● Add Index
#--------------------------------------------------------------------------
def add_index(value = 0)
@com_index += value
if !@continue_enabled and @com_index == 1
@com_index = 2 if value == 1
@com_index = 0 if value == -1
end
@com_index = 0 if @com_index > @com_index_max
@com_index = @com_index_max if @com_index < 0
end
#--------------------------------------------------------------------------
# ● Refresh Index
#--------------------------------------------------------------------------
def refresh_index
@com_index_old = @com_index
Sound.play_cursor
end
#--------------------------------------------------------------------------
# ● Command New Game
#--------------------------------------------------------------------------
def command_new_game
Sound.play_ok
DataManager.setup_new_game
fadeout_all
$game_map.autoplay
SceneManager.goto(Scene_Map)
end
#--------------------------------------------------------------------------
# ● Command Continue
#--------------------------------------------------------------------------
def command_continue
if !@continue_enabled
Sound.play_cancel
return
else
Sound.play_ok
end
SceneManager.call(Scene_Load)
end
#--------------------------------------------------------------------------
# ● Command Shutdown
#--------------------------------------------------------------------------
def command_shutdown
Sound.play_ok
fadeout_all
SceneManager.exit
end
#--------------------------------------------------------------------------
# ● play_title_music
#--------------------------------------------------------------------------
def play_title_music
$data_system.title_bgm.play
RPG::BGS.stop
RPG::ME.stop
end
#--------------------------------------------------------------------------
# ● Fadeout_all
#--------------------------------------------------------------------------
def fadeout_all(time = 1000)
RPG::BGM.fade(time)
RPG::BGS.fade(time)
RPG::ME.fade(time)
Graphics.fadeout(time * Graphics.frame_rate / 1000)
RPG::BGM.stop
RPG::BGS.stop
RPG::ME.stop
end
end
$mog_rgss3_rin_title_screen = true