Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

why why why?!?!?!

Aran

Member

Why does anytime I try to return to the map from the gameover screen it'll teleport, but then keep running gameover over and over again. I cleared the gameover flag too!
EDIT: Nevermind. But why does it keep repeating when I use the Game Over event, but when I use
Code:
$game_temp.gameover = true
it works... for the most part.
 
Yeah I was about to post the exact same thing. I really don't understand why :s

EDIT: Here's the script I (And maybe Aran ;) ) are using.
Code:
#==============================================================================
# ** 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
 

Aran

Member

Oh! yeah! It worked!

Here (it's still a little messy right now, but I'm gonna model it up before i post it in the Submitted Scripts)

Code:
module Save
  
    def self.add_save(map_id=1,event_id=0)
      @saves = {}
      unless @saves.keys.size < 0
        @saves.replace({map_id=> event_id})    
      else
        @saves[map_id] = event_id
      end
    end
    
    def self.saves
      return @saves
    end
    
end
  
class Scene_Gameover
  
  alias save_scngover_upd update
  
  def update
    @map_id = Save.saves.keys.first
    @event_id = Save.saves.values.first    
    @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
    @x = @map.events[@event_id].x
    @y = @map.events[@event_id].y
    save_scngover_upd
    if Input.trigger?(Input::C)
      save_scngover_upd
      $game_temp.gameover = false
      $game_map.setup(@map_id)
      $game_player.moveto(@x,@y)
      $scene=Scene_Map.new
      $game_map.refresh
    end
  end 
    
end

In your Save/Check Point event put this:
Code:
Save.add_save($game_map.map_id, [color=red][i]event id[/i][/color])

It's not full proof yet because if you never touch a checkpoint space then it'll give you an error. But it works when you follow all the rules!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top