I need help with this part of code. If somone can explain it for me it would be nice
# Main loop
loop do
# Updatera game screen
Graphics.update
# Updatera input information
Input.update
# Frame Update
update
# avbryt loop om screen är ändrad
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose everything
@sprite.bitmap.dispose
@sprite.dispose
@command_window.dispose
Graphics.transition(40)
end
I will alsow add the rest of the code so you can se from what im working with. some of the comments in the script is in swedish.
#==============================================================================
#Detta scriptet gör så att när man dör så kommer det upp en meny efter
#"GAME OVER" senen där man får välja om man vill loada last save, andra sparade
#saves eller om man vill gå tillbacks till start menyn.
#==============================================================================
#Detta gör så att detta scriptet är länkat till scriptet "scene_Gameover"
class Scene_Gameover
#------------------------------------------------------------------------------
# Main Processing
#------------------------------------------------------------------------------
def main
# gör game over graphic
@sprite = Sprite.new
# Stänger av allt onödigt ljud som annars skulle spelas upp i end game menyn.
$game_system.bgm_play(nil)
$game_system.bgs_play(nil)
$game_system.me_play(nil)
$game_system.se_play(nil)
# verkställer övergång
Graphics.transition(75)
# Förbereder övergången
Graphics.freeze
# Spelar upp lite musik i game over grapic
$game_system.me_play($data_system.gameover_me)
# Skapar Game over grapich
@sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
# avslutar övergången
Graphics.transition(120)
@sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
# Skapar command window
s1 = "Load Last Save"
s2 = "Load Game"
s3 = "Return to Title"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.back_opacity = 200
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 370 - @command_window.height / 2
# Här avgörs det om det finns någont sparat spel i spelet.
# om det inte finns något sparat så tas "Load Game" alternativet bort.
@continue_enabled = false
for i in 0..3
# Om det finns ett save i gamet.
if FileTest.exist?("Save#{i+1}.rxdata")
# Tillåt "Load Game" alternativet.
@continue_enabled = true
end
end
# om "Load Game" alternativet är activit.
if @continue_enabled
# aktivera "Load Game" kanppen
@command_window.index = 1
else
# annars avaktivera "Load Game" knappen.
@command_window.disable_item(1)
end
# tillåt "load last save" alternativet
@restart_enabled = true
# Avgör om det finns ett save i det nuvarande spelet.
# om det finns ett save i det nuvarande spelet
if $game_system.last_save < 1
# aktivera "Load last save" alternativet
@restart_enabled = false
end
# om "Load last save" är avaktiverat
if @restart_enabled == false
# avaktivera "Load last save" knappen
@command_window.disable_item(0)
end
# avslutar övergången
Graphics.transition(120)
# Main loop
loop do
# Updatera game screen
Graphics.update
# Updatera input information
Input.update
# Frame Update
update
# avbryt loop om screen är ändrad
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose everything
@sprite.bitmap.dispose
@sprite.dispose
@command_window.dispose
Graphics.transition(40)
end
#------------------------------------------------------------------------------
# Frame Update
#------------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If B button was pressed
if Input.trigger?(Input::B)/>
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 #to quick restart
command_to_Restart
when 1 #to load
command_Load
when 2 #to title
command_title
end
return
end
end
#------------------------------------------------------------------------------
# Process When Choosing [Quick Restart] Command
#------------------------------------------------------------------------------
def command_to_Restart
# If Restart is disabled
unless @restart_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)
#Quick Load save data
file = File.open("Save#{$game_system.last_save}.rxdata", "rb")
read_save_data(file)
file.close
# Restore BGM and BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#------------------------------------------------------------------------------
# Process When Choosing [Load Game] Command
#------------------------------------------------------------------------------
def command_Load
# If Restart is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
#Play desicion SE
$game_system.se_play($data_system.decision_se)
#Load Scene_load
$scene = Scene_Load.new
end
#------------------------------------------------------------------------------
# Process When Choosing [Return to Title] Command
#------------------------------------------------------------------------------
def command_title
#Play desicion SE
$game_system.se_play($data_system.decision_se)
$scene = Scene_Title.new
end
#------------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#------------------------------------------------------------------------------
def read_save_data(file)
# Read character data for drawing save file
characters = Marshal.load(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
# Read each type of game object
$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)
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
# Load map
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# Refresh party members
$game_party.refresh
end
# If battle test
if $BTEST
$scene = nil
end
end
class Game_System
attr_accessor :last_save
alias gg_init_quick_restart_lat initialize
def initialize
@last_save = 0
return gg_init_quick_restart_lat
end
end
class Scene_Save
alias gg_save_last_save_lat on_decision
def on_decision(filename)
$game_system.last_save = @file_index + 1
gg_save_last_save_lat(filename)
end
end

New Topic/Question
Reply



MultiQuote






|