Advertisement
jwideman

Map GameOver

Mar 10th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. #----------------------------------------------------------------------------
  2. # Map GameOver
  3. #----------------------------------------------------------------------------
  4. # Created by Joel Wideman
  5. #----------------------------------------------------------------------------
  6. # For use with RPG Maker VX Ace, compatibility with other software is unknown
  7. #----------------------------------------------------------------------------
  8. # Please credit if you use or modify.
  9. # You may use in commercial or non-commercial works.
  10. # You may modify, including translation, and redistribute.
  11. # Please don't redistribute unaltered.
  12. #----------------------------------------------------------------------------
  13. # Overrides: Scene_Gameover and Window_GameEnd
  14. #----------------------------------------------------------------------------
  15. # Change the GameOver scene to use the map as background and add a menu to
  16. # reload the game or quit directly, instead of going to the title screen.
  17. # You can use an image for the game over text. Image should be named
  18. # "Game_Over.png" (no quotes) and placed in "Graphics/System/"
  19. #----------------------------------------------------------------------------
  20. class Scene_Gameover < Scene_Base
  21.  
  22. #--------------------------------------------------------------------------
  23. # Override: start
  24. # Removes the call to fadeout the graphics
  25. #--------------------------------------------------------------------------
  26. def start
  27. super
  28. play_gameover_music
  29. create_background
  30. draw_game_over if !create_foreground
  31. create_command_window
  32. end
  33.  
  34. #--------------------------------------------------------------------------
  35. # Override: update
  36. # Removes the call to go to the title scene
  37. #--------------------------------------------------------------------------
  38. def update
  39. super
  40. end
  41.  
  42. #--------------------------------------------------------------------------
  43. # Override: create_background
  44. # Replaces the GameOver image with the background
  45. #--------------------------------------------------------------------------
  46. def create_background
  47. @background_sprite = Sprite.new
  48. @background_sprite.bitmap = SceneManager.background_bitmap
  49. @background_sprite.color.set(16, 16, 16, 128)
  50. end
  51.  
  52. #--------------------------------------------------------------------------
  53. # Create Foreground
  54. #--------------------------------------------------------------------------
  55. def create_foreground
  56. return false if Dir.glob("Graphics/System/Game_Over.*").empty?
  57. @foreground_sprite = Sprite.new
  58. @foreground_sprite.bitmap = Cache.system("Game_Over")
  59. return true
  60. end
  61.  
  62. #--------------------------------------------------------------------------
  63. # Override: dispose_background
  64. # Changed to free foreground_sprite and background_sprite
  65. #--------------------------------------------------------------------------
  66. def dispose_background
  67. @foreground_sprite.bitmap.dispose
  68. @foreground_sprite.dispose
  69. @background_sprite.bitmap.dispose
  70. @background_sprite.dispose
  71. end
  72.  
  73. #--------------------------------------------------------------------------
  74. # * Draw Game Over
  75. #--------------------------------------------------------------------------
  76. def draw_game_over
  77. @foreground_sprite = Sprite.new
  78. @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  79. @foreground_sprite.z = 100
  80. @foreground_sprite.bitmap.font.size = 96
  81. rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)
  82. @foreground_sprite.bitmap.draw_text(rect, "Game Over", 1)
  83. end
  84.  
  85. #--------------------------------------------------------------------------
  86. # Override: create_command_window
  87. # Removes cancel and adds continue
  88. #--------------------------------------------------------------------------
  89. def create_command_window
  90. @command_window = Window_GameOver.new
  91. @command_window.set_handler(:continue, method(:command_continue))
  92. @command_window.set_handler(:to_title, method(:command_to_title))
  93. @command_window.set_handler(:shutdown, method(:command_shutdown))
  94. end
  95. #--------------------------------------------------------------------------
  96. # * [Continue] Command
  97. #--------------------------------------------------------------------------
  98. def command_continue
  99. close_command_window
  100. SceneManager.call(Scene_Load)
  101. end
  102. #--------------------------------------------------------------------------
  103. # Copied from Scene_End
  104. # Terribly kludgy, but I don't know the right way to do it, if you even can
  105. #--------------------------------------------------------------------------
  106. #--------------------------------------------------------------------------
  107. # * Close Command Window
  108. #--------------------------------------------------------------------------
  109. def close_command_window
  110. @command_window.close
  111. update until @command_window.close?
  112. end
  113. #--------------------------------------------------------------------------
  114. # * [Go to Title] Command
  115. #--------------------------------------------------------------------------
  116. def command_to_title
  117. close_command_window
  118. fadeout_all
  119. SceneManager.goto(Scene_Title)
  120. end
  121. #--------------------------------------------------------------------------
  122. # * [Shut Down] Command
  123. #--------------------------------------------------------------------------
  124. def command_shutdown
  125. close_command_window
  126. fadeout_all
  127. SceneManager.exit
  128. end
  129. end
  130.  
  131. class Window_GameOver < Window_GameEnd
  132. #--------------------------------------------------------------------------
  133. # * Create Command List
  134. # Removes cancel and adds continue
  135. #--------------------------------------------------------------------------
  136. def make_command_list
  137. add_command(Vocab::continue, :continue)
  138. add_command(Vocab::to_title, :to_title)
  139. add_command(Vocab::shutdown, :shutdown)
  140. end
  141. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement