diablosbud
Member
I am making my own Game Over menu because I am making it work with Command_Rotate. I have all of the script written to the best of my ability due to the fact this is my first script. I am getting a Syntax Error, but do not know what is causing it. If you could please help me find why the Syntax Error is caused and, how to fix it, when I release the script I will credit you.
khmp: Code tags around code please diablosbud. It's the pound sign to the left of quote. You can delete this line when you see it.
Code:
#===============================================================================
# Game Over Menu Script V1.0 ~By Diablosbud~
#-------------------------------------------------------------------------------
# Make your Gameover screen easier to use, and cooler with this script I made
# for Command_Rotate.
#
# Requirements:
# -Command_Rotate script
#
# Compatibility:
# -I am unsure yet if this script is compatible with the SDK
#
# !If used please credit Diablosbud as a scripter or something alike!
#===============================================================================
class Scene_Gameover
def main
$newvar2 = 0
# Make command window
s1 = "Load Game"
s2 = "Exit Game"
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
if @continue_enabled
@choices.index = 1
else
@disabled_item = [0]
end
# Using Command_Rotate
@choices = Command_Rotate.new([s1,s2],320,380,100,0,40,"Times New Roman",
@disabled_item,Color.new(255, 0, 0, 108))
# Make game over graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
# Play game over ME
$game_system.me_play($data_system.gameover_me)
# Stop playing Gameover ME
Audio.me_stop
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of Command_Rotate
@choices.dispose
# Dispose of title graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# Frame Update
#--------------------------------------------------------------------------
def update
# Update Command_Rotate
@choices.update
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @choices.index
when 0 # Load game
command_continue
when 1 # Exit Game
command_exit
# Using Command_Rotate
@choices = Command_Rotate.new([c1,c2],320,380,100,0,40,"Times New Roman",
@disabled_item,Color.new(255, 0, 0, 108))
end
end
end
#--------------------------------------------------------------------------
# Command: Continue
#--------------------------------------------------------------------------
def command_continue
# If continue is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# Battle Test
#--------------------------------------------------------------------------
def battle_test
# Load database (for battle test)
$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")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$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 party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
#--------------------------------------------------------------------------
# Command: Exit
#--------------------------------------------------------------------------
def command_exit
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Show new choices
c1 = "To Titlescreen"
c2 = "Shutdown"
def update
# Update Command_Rotate
@choices.update
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @choices.index
when 0 # To Titlescreen
command_to_title
when 1 # Shutdown
command_shutdown
# Using Command_Rotate
@choices = Command_Rotate.new([s1,s2],320,380,100,0,40,"Times New Roman",
@disabled_item,Color.new(255, 0, 0, 108))
end
#--------------------------------------------------------------------------
# Command: To Title
#--------------------------------------------------------------------------
def command_to_title
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to title screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# Command: Shutdown
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Shutdown
$scene = nil
end
end
end
Code:
#=========================================================
# Command_Rotate
#---------------------------------------------------------
#
# Created by LordSith
# email: lordsith@globetrotter.net
# Version: 1.1
# Date: 2007-06-08
#---------------------------------------------------------
#
#=========================================================
def coords(x=0,y="")
if y.is_a?(String)
if x==0
x=$game_player.screen_x
y=$game_player.screen_y
else
y=$game_map.events[x].screen_y
x=$game_map.events[x].screen_x
end
return [x,y]
end
if x.is_a?(String)
if y==0
x=$game_player.screen_x
y=$game_player.screen_y
else
x=$game_map.events[y].screen_x
y=$game_map.events[y].screen_y
end
return [x,y]
end
return [x,y]
end
def angle(x1,y1,x2,y2)
return 180*Math.atan2(x2-x1,y2-y1)/Math::PI
end
def ecart(id1,id2=0,y1="",y2="")
x1=coords(id1,y1).at(0)
y1=coords(id1,y1).at(1)
x2=coords(id2,y2).at(0)
y2=coords(id2,y2).at(1)
return ((x1-x2)**2+(y1-y2)**2)**0.5
end
class Command_Rotate
attr_accessor:index
def initialize(choices, x=400, y=240, ray=200, choices0=0,
size=20, font=$defaultfonttype, disabled_items=nil,
disabledcolor=Color.new(255, 255, 255, 108))
@sprite=[]
@positions=[]
@options=choices
@disabledcolor=disabledcolor
@ray=ray
@angle=0
@disabled_items = disabled_items
x,y=coords(x,y)
@x,@y=x,y
n=0
for c in choices
if disabled_items.include?(n) and disabled_items != nil
sprite=Sprite_text.new(c,size,font,true,@disabledcolor)
else
sprite=Sprite_text.new(c,size,font)
end
sprite.sprite.ox=sprite.sprite.bitmap.width/2
sprite.sprite.oy=sprite.sprite.bitmap.height/2
teta=n*360/choices.size
@sprite+=[sprite]
@positions+=[teta]
@delay=0
n+=1
end
@angle=(@options.size-choices0)*2*Math::PI/@options.size
@selected=@options[choices0]
@index_self=0
update
end
def update
@angle-=(@angle-(@options.size-@index_self)*2*Math::PI/@options.size)/8
for n in 0..@sprite.size-1
sprite=@sprite.at(n)
a=@positions.at(n)*Math::PI/180
sprite.sprite.x=0
sprite.sprite.x+=@x
sprite.sprite.y=@ray*Math.sin(a+@angle)/2
sprite.sprite.y+=@y
sprite.sprite.zoom_x=sprite.sprite.zoom_y=(Math.cos(a+@angle)+3)/4
sprite.sprite.opacity=(1+Math.cos(a+@angle))*255/2
end
@delay-=1
if @delay<=0
if Input.trigger?(Input::DOWN) or Input.trigger?(Input::RIGHT)
@index_self+=1
@selected=@options[@index_self%@sprite.size]
@index = @options.index(@selected)
end
if Input.trigger?(Input::UP) or Input.trigger?(Input::LEFT)
@index_self-=1
@selected=@options[@index_self%@sprite.size]
@index = @options.index(@selected)
end
@delay=1
end
end
def dispose
for sprite in @sprite
sprite.dispose
end
end
end
class Sprite_text
def xy(x,y)
@x=x
@y=y
end
attr_accessor :sprite ,:vx ,:vy
def update
angle=Math.atan2(@vx,@vy)
vx=2*Math.sin(angle)
vy=2*Math.cos(angle)
@x+=vx
@y+=vy
@sprite.x =@x
@sprite.y =@y
@sprite.opacity-=4
if @x>640 or @x<0 or @y>480 or @y<0 or @sprite.opacity<=0
@sprite.bitmap.dispose
@sprite=nil
return true
end
return false
end
def initialize(text="nil",size=23,font=$defaultfonttype,disabled=false,
disabledcolor=Color.new(255, 255, 255, 108),vx=0,vy=0)
text=text.to_s
@sprite=Sprite.new
@sprite.bitmap = Bitmap.new(1,1)
@sprite.bitmap.font.name = font
@sprite.bitmap.font.size = size
lx=@sprite.bitmap.text_size(text).width
ly=@sprite.bitmap.text_size(text).height
@vx=vx
@vy=vy
shadow=1
@sprite.bitmap = Bitmap.new(lx+shadow, ly+shadow)
@sprite.bitmap.font.name = font
@sprite.bitmap.font.size = size
@sprite.z = 5000
@sprite.x =@x=320.0
@sprite.y =@y=240.0
@sprite.bitmap.font.color = Color.new(0,0,0,255)
@sprite.bitmap.draw_text(Rect.new(shadow,shadow,lx+shadow,ly+shadow), text, 0)
if disabled
@sprite.bitmap.font.color = disabledcolor
else
@sprite.bitmap.font.color = Color.new(255,255,255,255)
end
@sprite.bitmap.draw_text(Rect.new(0,0,lx,ly),text, 0)
end
def dispose
if @sprite.bitmap != nil
@sprite.bitmap.dispose
end
end
end
khmp: Code tags around code please diablosbud. It's the pound sign to the left of quote. You can delete this line when you see it.