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

Script Spoiler
  1. #------------------------------------------------------------------------------
  2. #==============================================================================
  3. #==============================================================================
  4. #====================*Law's 3-Image Gameover Screen*===========================
  5. #=========================Author: The Law G14==================================
  6. #============================Version 1.0=======================================
  7. #==============================================================================
  8. #------------------------------------------------------------------------------
  9. #==============================================================================
  10. # ** Module_Constants
  11. #------------------------------------------------------------------------------
  12. #  This module handles all the constants used in the script.
  13. #==============================================================================
  14.  
  15. module Constants
  16.  
  17. Menu_Img = true
  18.  
  19. # Names of graphic files which are found in Graphics/Titles
  20.  
  21. # Return To Title
  22. Title_Img = ["title", "title_active"]
  23. Title_Img_x = 422 # Horizontal position
  24. Title_Img_y = 200 # Vertical position
  25.  
  26. # Load Game
  27. Load_Img = ["load", "load_active"]
  28. Load_Img_x = 410 # Horizontal position
  29. Load_Img_y = 260 # Vertical position
  30.  
  31. # Quit Game
  32. Quit_Img = ["quit", "quit_active"]
  33. Quit_Img_x = 423 # Horizontal position
  34. Quit_Img_y = 320 # Vertical position
  35.  
  36.  
  37. # When continuity new invalid ( 0:Translucency / 1:Appointing the picture )
  38. Load_Disabled_Type = 0
  39.  
  40. # Picture when continuing invalid
  41. Load_Img_Disabled = ["load_Disabled", "load_Disabled_active"]
  42.  
  43. # Blending method of picture ( 0:Normal / 1:Addition / 2:Subtraction )
  44. Blend_Type = 0
  45.  
  46. # ---Settings if using text for the menu options---
  47.  
  48. # Original Menu command text string
  49. Menu_Title = "To Title" # New Game
  50. Menu_Load = "Load Game" # Continue
  51. Menu_Quit = "End Game" # Shutdown
  52.  
  53. # If true, opacity equals zero; if false, then opacity equals Window_Opacity
  54. Window_Trans = false
  55.  
  56. # Opacity of window
  57. Window_Opacity = 160
  58.  
  59. # Width of window
  60. Window_Width = 192
  61.  
  62. # Horizontal alignment of window ( 0: by Coordinates / 1: Left / 2: Center / 3:Right )
  63. Window_Align = 2
  64.  
  65. # If "by coordinates", positions the window horizontally
  66. Window_Pos_x = 0
  67.  
  68. # Vertical position of window (0: by Coordinates / 1: Top / 2: Center / 3: Bottom )
  69. Window_VAlign = 0
  70.  
  71. # If "by coordinates", positions the window vertically
  72. Window_Pos_y = 288
  73.  
  74. end
  75.  
  76. #==============================================================================
  77. # ** Scene_Gameover
  78. #------------------------------------------------------------------------------
  79. #  This class performs game over screen processing.
  80. #==============================================================================
  81.  
  82. class Scene_Gameover
  83.   #--------------------------------------------------------------------------
  84.   # * Object Initialization
  85.   #     menu_index : command cursor's initial position
  86.   #--------------------------------------------------------------------------
  87.   def initialize(menu_index = 0)
  88.     @menu_index = menu_index
  89.   end  
  90.   #--------------------------------------------------------------------------
  91.   # * Main Processing
  92.   #--------------------------------------------------------------------------
  93.   def main
  94.     # Make game over graphic
  95.     @sprite = Sprite.new
  96.     @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
  97.     # Make command window
  98.     s1 = Constants::Menu_Title
  99.     s2 = Constants::Menu_Load
  100.     s3 = Constants::Menu_Quit
  101.     w = Constants::Window_Width
  102.     @command_window = Window_Command.new(w, [s1, s2, s3])
  103.     @command_window.index = @menu_index  
  104.     #@command_window.x = 200
  105.     #@command_window.y = 200
  106.     if Constants::Window_Trans
  107.       @command_window.opacity = 0
  108.     else
  109.       @command_window.back_opacity = Constants::Window_Opacity
  110.     end
  111.     # Positioning the window
  112.     case Constants::Window_Align
  113.     when 0
  114.       @command_window.x = Constants::Window_Pos_x
  115.     when 1
  116.       @command_window.x = 0
  117.     when 2
  118.       @command_window.x = ( 640 - @command_window.width ) / 2
  119.     when 3
  120.       @command_window.x = 640 - @command_window.width
  121.     end
  122.     case Constants::Window_VAlign
  123.     when 0
  124.       @command_window.y = Constants::Window_Pos_y
  125.     when 1
  126.       @command_window.y = 0
  127.     when 2
  128.       @command_window.y = ( 480 - @command_window.height ) / 2
  129.     when 3
  130.       @command_window.y = 480 - @command_window.height
  131.     end
  132.     @continue_enabled = false
  133.     for i in 0..3
  134.       if FileTest.exist?("Save#{i+1}.rxdata")
  135.         @continue_enabled = true
  136.       end
  137.     end
  138.     # If there are no save files disable load.
  139.     if @continue_enabled
  140.       @command_window.index = 1
  141.     else
  142.       @command_window.disable_item(1)
  143.     end
  144.     if Constants::Menu_Img
  145.       @command_window.visible = false
  146.       @command_img0 = Sprite.new
  147.       @command_img0.blend_type = Constants::Blend_Type
  148.       @command_img0.bitmap = RPG::Cache.title(Constants::Title_Img[0])
  149.       @command_img0.x = Constants::Title_Img_x
  150.       @command_img0.y = Constants::Title_Img_y
  151.       @command_img1 = Sprite.new
  152.       @command_img1.blend_type = Constants::Blend_Type
  153.       @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img[0])
  154.       @command_img1.x = Constants::Load_Img_x
  155.       @command_img1.y = Constants::Load_Img_y
  156.       @command_img2 = Sprite.new
  157.       @command_img2.blend_type = Constants::Blend_Type
  158.       @command_img2.bitmap = RPG::Cache.title(Constants::Quit_Img[0])
  159.       @command_img2.x = Constants::Quit_Img_x
  160.       @command_img2.y = Constants::Quit_Img_y
  161.     end
  162.     if @continue_enabled
  163.       select_img_item(1)
  164.     else
  165.       case Constants::Load_Disabled_Type
  166.       when 0
  167.         @command_img1.opacity = 160
  168.       when 1
  169.         @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img_Disabled[0])
  170.       end
  171.     end  
  172.     # Stop BGM and BGS
  173.     $game_system.bgm_play(nil)
  174.     $game_system.bgs_play(nil)
  175.     # Play game over ME
  176.     $game_system.me_play($data_system.gameover_me)
  177.     # Execute transition
  178.     Graphics.transition(120)
  179.     # Main loop
  180.     loop {
  181.       # Update game screen
  182.       Graphics.update
  183.       # Update input information
  184.       Input.update
  185.       # Frame update
  186.       update
  187.       # Abort loop if screen is changed
  188.       break if $scene != self
  189.     }
  190.     # Prepare for transition
  191.     Graphics.freeze
  192.     # Dispose of game over graphic
  193.     @command_window.dispose
  194.     if Constants::Menu_Img
  195.       @command_img0.dispose
  196.       @command_img1.dispose
  197.       @command_img2.dispose
  198.     end
  199.     @sprite.bitmap.dispose
  200.     @sprite.dispose
  201.     # Execute transition
  202.     Graphics.transition(40)
  203.     # Prepare for transition
  204.     Graphics.freeze
  205.     # If battle test
  206.     if $BTEST
  207.       $scene = nil
  208.     end
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # * Frame Update
  212.   #--------------------------------------------------------------------------
  213.   def update
  214.     # Update windows
  215.     @command_window.update
  216.     if Constants::Menu_Img
  217.       if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
  218.         select_img_item(@command_window.index)
  219.       end
  220.     end
  221.     # If command window is active: call update_command
  222.     if @command_window.active
  223.       update_command
  224.     end  
  225.   end  
  226.   #--------------------------------------------------------------------------
  227.   # * Frame Update (when command window is active)
  228.   #--------------------------------------------------------------------------
  229.   def update_command    
  230.     # If B button was pressed
  231.     if Input.trigger?(Input::B)
  232.       # Play cancel SE
  233.       $game_system.se_play($data_system.cancel_se)
  234.       # Switch to title screen
  235.       $scene = Scene_Title.new
  236.     # If C button was pressed
  237.     elsif Input.trigger?(Input::C)
  238.       # Branch by command window cursor position
  239.       case @command_window.index
  240.       when 0  # Return to title
  241.         # Play decision SE
  242.         $game_system.se_play($data_system.decision_se)
  243.         # Switch to item screen
  244.         $scene = Scene_Title.new
  245.       when 1  # Load Game
  246.         unless @continue_enabled
  247.           # Play buzzer SE
  248.           $game_system.se_play($data_system.buzzer_se)
  249.           return
  250.         end      
  251.         # Play decision SE
  252.         $game_system.se_play($data_system.decision_se)
  253.         # Switch to load game screen
  254.         $scene = Scene_Load.new          
  255.       when 2  # End Game
  256.         # Play decision SE
  257.         $game_system.se_play($data_system.decision_se)            
  258.       # Switch to title screen
  259.       $scene = nil
  260.       end
  261.     end
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # * Select Image Item (Index)
  265.   #--------------------------------------------------------------------------
  266.   def select_img_item(index)
  267.     @command_img0.bitmap = RPG::Cache.title(Constants::Title_Img[0])
  268.     case Constants::Load_Disabled_Type
  269.     when 0
  270.       @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img[0])
  271.     when 1
  272.       @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img_Disabled[0])
  273.     end
  274.     @command_img2.bitmap = RPG::Cache.title(Constants::Quit_Img[0])
  275.     case @command_window.index
  276.     when 0 # To Title
  277.       @command_img0.bitmap = RPG::Cache.title(Constants::Title_Img[1])
  278.     when 1 # Load Game
  279.       case Constants::Load_Disabled_Type
  280.       when 0
  281.         @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img[1])
  282.       when 1
  283.         @command_img1.bitmap = RPG::Cache.title(Constants::Load_Img_Disabled[1])
  284.       end
  285.     when 2 # Quit Game
  286.       @command_img2.bitmap = RPG::Cache.title(Constants::Quit_Img[1])
  287.     end
  288.   end
  289. end
  290.  
Expand to see the code.


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 :)
I like this. I think that this is a good miniscript and is something that is small but useful.
Thanks, glad you liked it :) It is pretty small but it does serve a pretty cool purpose, like you said. Thanks again :D

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75126