#==============================================================================
# ** Checkpoint script
# Written by: Dargor
# Date: 14/02/07
# Version 1.0
#==============================================================================
#==============================================================================
# ** Checkpoint
#------------------------------------------------------------------------------
# This class handles checkpoints.
#==============================================================================
class Checkpoint
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :current_checkpoint # ID of the checkpoint
attr_accessor :coordinates # Coordinates associated to current_checkpoint
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@current_checkpoint = 0
@coordinates = [1,0,0]
end
#--------------------------------------------------------------------------
# * Checkpoints: Returns informations on a checkpoint (id)
#--------------------------------------------------------------------------
def checkpoints(id)
#--------------------------------------------------------------------------
# EDIT HERE
# when checkpoint_id
# return [map_id,x,y]
# ...
#--------------------------------------------------------------------------
case id
when 0
return[1,0,0]
when 1
return[2,10,10]
else
return[1,5,5]
end
end
#--------------------------------------------------------------------------
# * Save: Store informations on a checkpoint
#--------------------------------------------------------------------------
def save(id)
@current_checkpoint = id
@coordinates = checkpoints(id)
end
#--------------------------------------------------------------------------
# * Restart: Bring the player back to a checkpoint
#--------------------------------------------------------------------------
def restart
# Set gameover flag to false
$game_temp.gameover = false
# Set up initial map position
$game_map.setup(@coordinates[0])
# Move player to initial position
$game_player.moveto(@coordinates[1], @coordinates[2])
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias listing
#--------------------------------------------------------------------------
alias checkpoint_command_new_game command_new_game
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
$checkpoint = Checkpoint.new
checkpoint_command_new_game
end
end
#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
# This class performs game over screen processing.
#==============================================================================
class Scene_Gameover
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If C button was pressed
if Input.trigger?(Input::C)
# Switch to a checkpoint
$checkpoint.restart
end
end
end