Code:
#==============================================================================
# â– Scene_Title
#------------------------------------------------------------------------------
#  This class handles the title screen.
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# â— Set up the game
#--------------------------------------------------------------------------
def main
# Check if a battle test is being conducted
if $BTEST
battle_test
return
end
# Move database data to memory
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# Draw system objects
$game_system = Game_System.new
# Draw title graphics
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
#draw press start button
@start = Sprite.new
@start.bitmap = RPG::Cache.picture("start")
@start.x = 140
@start.y = 240
@start.zoom_x = 2
@start.zoom_y = 2
@start_flash = 0
# Draw the command window
s1 = "New Game" # 0
s2 = "Continue" # 1
s3 = "Exit" # 2
commands = [s2,s1,s3]
# Check if a game has already been saved. If so, enable the Continue button.
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# If continuing is allowed, select the Continue button.
if @continue_enabled == false
commands.delete("Continue")
end
@commands = Window_Command.new(192, commands)
@commands.opacity = 255
@commands.back_opacity = 255
@commands.x = 174
@commands.y = 164
@commands.width = 124
@commands.visible = false
@commands.active = false
# Play the title background music
$game_system.bgm_play($data_system.title_bgm)
# Stop any music effects or background sounds
Audio.me_stop
Audio.bgs_stop
# Update graphics and input
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
# Freeze graphics for transition
Graphics.freeze
# Erase the command window
@commands.dispose
# Erase the start button
@start.dispose
# Erase title graphics
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# â— Repond to user input from the command window
#--------------------------------------------------------------------------
def update
# Update the command window
@commands.update
# Update the Start Button
@start.update
@start_flash = (@start_flash + 1) % 50 if @commands.visible == false
case @start_flash
when 25
@start.visible = false
when 49
@start.visible = true
end
if Input.trigger?(Input::C) and @commands.visible != true
@commands.visible = true
@commands.active = true
@start.visible = false
return
end
if Input.trigger?(Input::B) and @commands.visible = true
@commands.visible = false
@commands.active = false
@start.visible = true
return
end
if Input.trigger?(Input::C) and @commands.active = true
case @commands.commands[@commands.index]
when "New Game" # New Game
command_new_game
when "Continue" # Continue
command_continue
when "Exit" # Shutdown
command_shutdown
end
end
end
#--------------------------------------------------------------------------
# â— Start a new game
#--------------------------------------------------------------------------
def command_new_game
# Play decision sound effect
$game_system.se_play($data_system.decision_se)
# Stop Title BGM
Audio.bgm_stop
# Initialize new game
Graphics.frame_count = 0
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up hero party
$game_party.setup_starting_members
# Set up opening map
$game_map.setup($data_system.start_map_id)
# Set up hero party's beginning location
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Set up lead character's map sprite graphic
$game_player.refresh
# Refresh the map
$game_map.autoplay
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# â— Continue a game
#--------------------------------------------------------------------------
def command_continue
unless @continue_enabled
$game_system.se_play($data_system.buzzer_se)
return
end
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
#$game_system.se_play($data_system.decision_se)
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
i = 0
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# â— Shutdown the game
#--------------------------------------------------------------------------
def command_shutdown
$game_system.se_play($data_system.decision_se)
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
$scene = nil
end
#--------------------------------------------------------------------------
# â— Start a battle test
#--------------------------------------------------------------------------
def battle_test
# Load information from database into memory
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
Graphics.frame_count = 0
# Initialize global classes
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up battle
$game_party.setup_battle_test_members
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Set up music and sound
$game_system.se_play($data_system.battle_start_se)
$game_system.bgm_play($game_system.battle_bgm)
$scene = Scene_Battle.new
end
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$pkmn = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
end
Is the script that I am using. How can I make it so that once Enter is pressed to display the "New game", "Continue" and Exit options a new BGM is played and the background is turned to black?