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.

LAWS 3-Image Gameover

LAWS 3-Image Gameover Screen

Version 1.0
The Law G14/TheScripter
11/5/09


Introduction

Another script I have at RRR. This is a nice little script that allows it so that when you have a gameover, you can return to the title screen, continue another save file, or quit the game. Also, it allows these options to be pictures that you can scroll through. So, essentially, this script is pretty much a three-image title screen except instead of being in the title screen, you’re in the gameover screen.

Features

-Allows you to go back to the title screen, load a saved game, or quit the game.

-Changes command window into three seperate pictures.

Script

[rgss]#------------------------------------------------------------------------------
#==============================================================================
#==============================================================================
#====================*Law's 3-Image Gameover Screen*===========================
#=========================Author: The Law G14==================================
#============================Version 1.0=======================================
#==============================================================================
#------------------------------------------------------------------------------
#==============================================================================
# ** Module_Constants
#------------------------------------------------------------------------------
#  This module handles all the constants used in the script.
#==============================================================================
 
module Constants
 
Menu_Img = true
 
# Names of graphic files which are found in Graphics/Titles
 
# Return To Title
Title_Img = ["title", "title_active"]
Title_Img_x = 422 # Horizontal position
Title_Img_y = 200 # Vertical position
 
# Load Game
Load_Img = ["load", "load_active"]
Load_Img_x = 410 # Horizontal position
Load_Img_y = 260 # Vertical position
 
# Quit Game
Quit_Img = ["quit", "quit_active"]
Quit_Img_x = 423 # Horizontal position
Quit_Img_y = 320 # Vertical position
 
 
# When continuity new invalid ( 0:Translucency / 1:Appointing the picture )
Load_Disabled_Type = 0
 
# Picture when continuing invalid
Load_Img_Disabled = ["load_Disabled", "load_Disabled_active"]
 
# Blending method of picture ( 0:Normal / 1:Addition / 2:Subtraction )
Blend_Type = 0
 
# ---Settings if using text for the menu options---
 
# Original Menu command text string
Menu_Title = "To Title" # New Game
Menu_Load = "Load Game" # Continue
Menu_Quit = "End Game" # Shutdown
 
# If true, opacity equals zero; if false, then opacity equals Window_Opacity
Window_Trans = false
 
# Opacity of window
Window_Opacity = 160
 
# Width of window
Window_Width = 192
 
# Horizontal alignment of window ( 0: by Coordinates / 1: Left / 2: Center / 3:Right )
Window_Align = 2
 
# If "by coordinates", positions the window horizontally
Window_Pos_x = 0
 
# Vertical position of window (0: by Coordinates / 1: Top / 2: Center / 3: Bottom )
Window_VAlign = 0
 
# If "by coordinates", positions the window vertically
Window_Pos_y = 288
 
end
 
#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  This class performs game over screen processing.
#==============================================================================
 
class Scene_Gameover
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end  
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make game over graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
    # Make command window
    s1 = Constants::Menu_Title
    s2 = Constants::Menu_Load
    s3 = Constants::Menu_Quit
    w = Constants::Window_Width
    @command_window = Window_Command.new(w, [s1, s2, s3])
    @command_window.index = @menu_index  
    #@command_window.x = 200
    #@command_window.y = 200
    if Constants::Window_Trans
      @command_window.opacity = 0
    else
      @command_window.back_opacity = Constants::Window_Opacity
    end
    # Positioning the window
    case Constants::Window_Align
    when 0
      @command_window.x = Constants::Window_Pos_x
    when 1
      @command_window.x = 0
    when 2
      @command_window.x = ( 640 - @command_window.width ) / 2
    when 3
      @command_window.x = 640 - @command_window.width
    end
    case Constants::Window_VAlign
    when 0
      @command_window.y = Constants::Window_Pos_y
    when 1
      @command_window.y = 0
    when 2
      @command_window.y = ( 480 - @command_window.height ) / 2
    when 3
      @command_window.y = 480 - @command_window.height
    end
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # If there are no save files disable load.
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    if Constants::Menu_Img
      @command_window.visible = false
      @command_img0 = Sprite.new
      @command_img0.blend_type = Constants::Blend_Type
      @command_img0.bitmap = RPG::Cache.title(Constants::Title_Img[0])
      @command_img0.x = Constants::Title_Img_x
      @command_img0.y = Constants::Title_Img_y
      @command_img1 = Sprite.new
      @command_img1.blend_type = Constants::Blend_Type
      @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img[0])
      @command_img1.x = Constants::Load_Img_x
      @command_img1.y = Constants::Load_Img_y
      @command_img2 = Sprite.new
      @command_img2.blend_type = Constants::Blend_Type
      @command_img2.bitmap = RPG::Cache.title(Constants::Quit_Img[0])
      @command_img2.x = Constants::Quit_Img_x
      @command_img2.y = Constants::Quit_Img_y
    end
    if @continue_enabled
      select_img_item(1)
    else
      case Constants::Load_Disabled_Type
      when 0
        @command_img1.opacity = 160
      when 1
        @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img_Disabled[0])
      end
    end  
    # Stop BGM and BGS
    $game_system.bgm_play(nil)
    $game_system.bgs_play(nil)
    # Play game over ME
    $game_system.me_play($data_system.gameover_me)
    # Execute transition
    Graphics.transition(120)
    # Main loop
    loop {
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      break if $scene != self
    }
    # Prepare for transition
    Graphics.freeze
    # Dispose of game over graphic
    @command_window.dispose
    if Constants::Menu_Img
      @command_img0.dispose
      @command_img1.dispose
      @command_img2.dispose
    end
    @sprite.bitmap.dispose
    @sprite.dispose
    # Execute transition
    Graphics.transition(40)
    # Prepare for transition
    Graphics.freeze
    # If battle test
    if $BTEST
      $scene = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    if Constants::Menu_Img
      if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
        select_img_item(@command_window.index)
      end
    end
    # If command window is active: call update_command
    if @command_window.active
      update_command
    end  
  end  
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command    
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to title screen
      $scene = Scene_Title.new
    # If C button was pressed
    elsif Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # Return to title
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Title.new
      when 1  # Load Game
        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 game screen
        $scene = Scene_Load.new          
      when 2  # End Game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)            
      # Switch to title screen
      $scene = nil
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Select Image Item (Index)
  #--------------------------------------------------------------------------
  def select_img_item(index)
    @command_img0.bitmap = RPG::Cache.title(Constants::Title_Img[0])
    case Constants::Load_Disabled_Type
    when 0
      @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img[0])
    when 1
      @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img_Disabled[0])
    end
    @command_img2.bitmap = RPG::Cache.title(Constants::Quit_Img[0])
    case @command_window.index
    when 0 # To Title
      @command_img0.bitmap = RPG::Cache.title(Constants::Title_Img[1])
    when 1 # Load Game
      case Constants::Load_Disabled_Type
      when 0
        @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img[1])
      when 1
        @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img_Disabled[1])
      end
    when 2 # Quit Game
      @command_img2.bitmap = RPG::Cache.title(Constants::Quit_Img[1])
    end
  end
end
 
[/rgss]

Compatibility

This script will most likely run into errors with scripts that change around the gameover screen.

Screenshot

None for this type of script.

Installation

For this script to work, you have to save 6 images into the Graphics/Titles section of your recourse manager. They should be named ‘title’, ‘title_active’, ‘load’, ‘load_active’, ‘quit’, and ‘quit_active’.

Terms and Conditions

Just credit it me where it's due :)

Special Thanks

Special Thanks to Paradog’s Three Image Title and Juan’s Custom Gameover Screen since this script is almost just a fusion of those two scripts :)
 

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