Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # +++ MOG&DP - Animated Gameover (v2.5) Unofficial+++
- #==============================================================================
- # Original By Moghunter
- # Edited By: Dark Paladin For Game Over Scene.
- # http://www.atelier-rgss.com/
- # http://dpalpro.blogspot.com/
- #==============================================================================
- # Animated Gameover screen with logo, random pictures and other visual effects.
- #==============================================================================
- #==============================================================================
- # Necessary Images
- #==============================================================================
- # Place all images in Graphics/Gameover/
- #
- # Particle.png (Opcional)
- # Animated.png (Opcional) Can change name
- #==============================================================================
- #==============================================================================
- # ● Histórico (Version History)
- #==============================================================================
- # V 2.5 Fixed return to title bug.
- # V 2.4 Unofficial edit: Script now can play a movie file before gameover scene.
- # V 2.3 (Unofficial Dark Paladin Edit)
- # - Changed script to work as a gameover screen instead of title
- # - Removed unessecary code
- # V 2.2 - It is now possible to put negative values to particles movement.
- # V 2.1 - Fixed bug when the amount of random images is less than 1.
- # V 2.0 - Added Animated Sprite. (Optional)
- # - Added random color particles.
- # - Added multiple layers of images. (Optional)
- # - Added the Wave effect in the text of the title.
- # - Option to set the speed of movement of the particles.
- # - Option to enable or not the tremor in the selection command.
- #
- # V 1.2 - Improved system dispose of images.
- #
- # V 1.1 - Option to skip right by pressing any key.
- # - Adding commands in pictures.
- # - Addition of cursor control.
- #==============================================================================
- module MOG_SCENE_GO_A
- #--------------------------------------------------------------------------
- # ▼ Movie ▼
- #--------------------------------------------------------------------------
- #Movie config
- #--------------------------------------------------------------------------
- # Play movie at gameover? true/false
- Play_Movie = false
- # Name of Movie in the Projectfolder/Movies folder
- Movie_Name = "big_buck_bunny"
- # Play Gameover music before video(true) or after(false)
- Start_Music = false
- #--------------------------------------------------------------------------
- # ▼ RANDOM BACKGROUND ▼
- #--------------------------------------------------------------------------
- #Picture config
- #--------------------------------------------------------------------------
- RANDOM_PICTURES = [
- "death-04", "death-01", "Title1", "death-02"
- #"Title4","Title5","Title6","Title7"
- ]
- #Time between random image transition.
- RANDOM_PICTURES_DURATION = 10#(sec)
- #Use random images true/false.
- RAMDOM_SELECTION = true
- #Speed of Picture scrolling. (Speed X , Speed Y)
- RANDOM_PICTURES_SCROLL_SPEED = [0,0]
- #--------------------------------------------------------------------------
- # ▼ MULTIPLE LAYERS ▼
- #--------------------------------------------------------------------------
- # Config for multiple layers. (There is no limit to how many)
- # usadas)
- #--------------------------------------------------------------------------
- # MULTIPLE_LAYERS = [ ["A",B,C,D], ["A",B,C,D], ["A",B,C D], ["A",B,C,D ], ....]
- #
- # A - Name of the image
- # B - Speed of Horizontal Scroll.
- # C - Speed of Vertical Scroll.
- # D - Type of Blending. (0 - Normal / 2 - Add / 3 - Substract)
- #
- MULTIPLE_LAYERS = [
- ["Layer1",1,0,1],
- ["Layer2",3,0,1],
- ["Layer3",0,0,0]
- # ["Layer4",0,0,0],
- # ["Layer5",0,0,0],
- # ["Layer6",0,0,0]
- ]
- #--------------------------------------------------------------------------
- # ▼ PARTICLES ▼
- #--------------------------------------------------------------------------
- # Adds animated particles to the screen
- # Place the image PARTICLE.png in folder Graphics/Gameover
- #--------------------------------------------------------------------------
- # Use Particles true/false.
- PARTICLE = true
- # Use Random Colors true/false.
- PARTICLE_RANDOM_COLOR = true
- # Type of Blending. (0,1,2)
- PARTICLE_BLEND_TYPE = 1
- # Speed configuration of the particles.
- PARTICLE_MOVEMENT_RANGE_X = 3
- PARTICLE_MOVEMENT_RANGE_Y = 3
- PARTICLE_ANGLE_RANGE = 3
- #--------------------------------------------------------------------------
- # ▼ WAVE TITLE ▼
- #--------------------------------------------------------------------------
- # Configure for the Title name Wave. Place the image in Graphics/Gameover
- #--------------------------------------------------------------------------
- # Wave Active true/false.
- TITLE_WAVE = true
- # TITLE_WAVE_CONFIG = [ POWER, LENGTH , SPEED]
- TITLE_WAVE_CONFIG = [6 , 232 , 360]
- # Filename for the Gameover text
- GameoverTextImage = "gameover"
- #--------------------------------------------------------------------------
- # ▼ ANIMATED_SPRITE ▼ (Opcional)
- #--------------------------------------------------------------------------
- # Adds an animated sprite to the background.
- # The number of frames is mesured from the height divide by the width
- # There is no limit to the number of frames you can have.
- # Place the image canbedefinedbelow.png (Jpg) in the Graphics/Gameover folder
- #--------------------------------------------------------------------------
- # Activate animated sprite true/false.
- ANIMATED_SPRITE = true
- # Sprite position.
- ANIMATED_SPRITE_POSITION = [20,-30]
- # Speed of Animation
- ANIMATED_SPRITE_SPEED = 10
- # Type of Blending. (0 - Normal / 2 - Add / 3 - Substract)
- ANIMATED_SPRITE_BLEND_TYPE = 1
- # Zoom size 1.0 is normal,
- ANIMATED_SPRITE_ZOOM = 2.7
- # Filename for the animated sprite
- Sprite_Fname = "ANIMATED"
- end
- #==============================================================================
- # ■ Cache Extension
- #==============================================================================
- module Cache
- def self.gameover(filename)
- load_bitmap("Graphics/Gameover/", filename)
- end
- def self.movies(filename)
- Graphics.play_movie("Movies/" + filename)
- end
- end
- #==============================================================================
- # ■ Window TitleCommand
- #==============================================================================
- class Window_GameEnd < Window_Command
- attr_reader :list
- end
- #==============================================================================
- # ■ Particle Title
- #==============================================================================
- class Particle_Title < Sprite
- include MOG_SCENE_GO_A
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- def initialize(viewport = nil)
- super(viewport)
- self.bitmap = Cache.gameover("Particle")
- self.tone.set(rand(255),rand(255), rand(255), 255) if PARTICLE_RANDOM_COLOR
- self.blend_type = PARTICLE_BLEND_TYPE
- @cw = self.bitmap.width
- @ch = self.bitmap.height
- @nx = PARTICLE_MOVEMENT_RANGE_X
- @ny = PARTICLE_MOVEMENT_RANGE_Y
- reset_setting
- end
- #--------------------------------------------------------------------------
- # ● Reset Setting
- #--------------------------------------------------------------------------
- def reset_setting
- zoom = (50 + rand(100)) / 100.1
- self.zoom_x = zoom
- self.zoom_y = zoom
- self.x = (rand(576) -32)
- self.y = rand(448 + @ch)
- self.opacity = 0
- self.angle = rand(360)
- nx2 = rand(@nx).abs
- nx2 = 1 if (@nx != 0 and nx2 < 1)
- @speed_x = @nx > 0 ? nx2 : @nx < 0 ? -nx2 : 0
- ny2 = rand(@ny).abs
- ny2 = 1 if (@ny != 0 and ny2 < 1)
- @speed_y = @ny > 0 ? ny2 : @ny < 0 ? -ny2 : 0
- @speed_a = [[rand(PARTICLE_ANGLE_RANGE), PARTICLE_ANGLE_RANGE].min, 0].max
- end
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- def dispose
- super
- self.bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- def update
- super
- self.x += @speed_x
- self.y -= @speed_y
- self.angle += @speed_a
- self.opacity += 5
- reset_setting if can_reset_setting?
- end
- #--------------------------------------------------------------------------
- # ● Can Reset Setting
- #--------------------------------------------------------------------------
- def can_reset_setting?
- return true if (self.x < -48 or self.x > 592)
- return true if (self.y < -48 or self.y > 464)
- return false
- end
- end
- #==============================================================================
- # ■ Multiple Layers Gameover
- #==============================================================================
- class Multiple_Layers_Gameover
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- def self.gameover(filename)
- load_bitmap("Graphics/Gameover/", filename)
- end
- def initialize(name = "", scroll_x = 0, scroll_y = 0, blend = 0, index = 0)
- @layer = Plane.new
- @layer.bitmap = Cache.gameover(name.to_s) rescue nil
- @layer.bitmap = Bitmap.new(32,32) if @layer.bitmap == nil
- @layer.z = 10 + index
- @layer.opacity = 0
- @layer.blend_type = blend
- @scroll_speed = [scroll_x, scroll_y]
- end
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- def dispose
- @layer.bitmap.dispose
- @layer.bitmap = nil
- @layer.dispose
- end
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- def update
- @layer.opacity += 2
- @layer.ox += @scroll_speed[0]
- @layer.oy += @scroll_speed[1]
- end
- end
- #==============================================================================
- # ■ Scene Gameover
- #==============================================================================
- class Scene_Gameover < Scene_Base
- include MOG_SCENE_GO_A
- #--------------------------------------------------------------------------
- # ● Start
- #--------------------------------------------------------------------------
- def start
- super
- @movie_active = Play_Movie
- dispose_all_sprites
- RPG::BGM.fade(2000)
- SceneManager.clear
- @phase = 1
- @phase_time = -1
- create_background
- create_light
- create_animated_object
- create_multiple_layers
- if Start_Music == true then play_gameover_music end
- create_movie if @movie_active
- if Start_Music == false then play_gameover_music end
- end
- #--------------------------------------------------------------------------
- # ● Create Gameover Movie
- #--------------------------------------------------------------------------
- def create_movie
- fadeout_frozen_graphics
- Cache.movies(Movie_Name)
- end
- #--------------------------------------------------------------------------
- # ● Create Multiple Layers
- #--------------------------------------------------------------------------
- def create_multiple_layers
- @m_layers = []
- index = 0
- for i in MULTIPLE_LAYERS
- @m_layers.push(Multiple_Layers_Gameover.new(i[0],i[1],i[2],i[3],index))
- index += 1
- end
- end
- #--------------------------------------------------------------------------
- # ● Create_Logo
- #--------------------------------------------------------------------------
- def create_animated_object
- return if !ANIMATED_SPRITE
- @object_index = 0
- @object_animation_speed = 0
- @object = Sprite.new
- @object.z = 98
- @object.opacity = 0
- @object.blend_type = ANIMATED_SPRITE_BLEND_TYPE
- @object.zoom_x = ANIMATED_SPRITE_ZOOM
- @object.zoom_y = ANIMATED_SPRITE_ZOOM
- @object_image = Cache.gameover(Sprite_Fname)
- @object_frame_max = @object_image.width / @object_image.height
- @object_width = @object_image.width / @object_frame_max
- @object.bitmap = Bitmap.new(@object_width,@object_image.height)
- @object.x = ANIMATED_SPRITE_POSITION[0]
- @object.y = ANIMATED_SPRITE_POSITION[1]
- make_object_bitmap
- end
- #--------------------------------------------------------------------------
- # ● create_background
- #--------------------------------------------------------------------------
- def create_background
- @rand_title_duration = 120
- @old_back_index = 0
- @sprite1 = Plane.new
- @sprite1.opacity = 0
- @sprite1.z = 1
- if RAMDOM_SELECTION
- execute_random_picture(false)
- else
- execute_random_picture(true)
- end
- @sprite2 = Sprite.new
- @sprite2.bitmap = Cache.gameover(GameoverTextImage)
- @sprite2.z = 140
- @sprite2.opacity = 0
- if TITLE_WAVE
- @sprite2.wave_amp = TITLE_WAVE_CONFIG[0]
- @sprite2.wave_length = TITLE_WAVE_CONFIG[1]
- @sprite2.wave_speed = TITLE_WAVE_CONFIG[2]
- end
- end
- #--------------------------------------------------------------------------
- # ● Create Light
- #--------------------------------------------------------------------------
- def create_light
- return unless PARTICLE
- @viewport_light = Viewport.new(-32, -32, 600, 480)
- @viewport_light.z = 50
- @light_bitmap =[]
- for i in 0...20
- @light_bitmap.push(Particle_Title.new(@viewport_light))
- end
- end
- #--------------------------------------------------------------------------
- # ● dispose Background1
- #--------------------------------------------------------------------------
- def dispose_background1
- @sprite1.bitmap.dispose
- @sprite1.bitmap = nil
- @sprite1.dispose
- @sprite1 = nil
- end
- #--------------------------------------------------------------------------
- # ● Dispose Background2
- #--------------------------------------------------------------------------
- def dispose_background2
- if @sprite2.bitmap != nil
- @sprite2.bitmap.dispose
- @sprite2.bitmap = nil
- @sprite2.dispose
- @sprite2 = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● Dispose Light
- #--------------------------------------------------------------------------
- def dispose_light
- return unless PARTICLE
- if @light_bitmap != nil
- for i in @light_bitmap
- i.dispose
- end
- @light_bitmap = nil
- end
- @viewport_light.dispose
- end
- #--------------------------------------------------------------------------
- # ● Dispose Multiple Layers
- #--------------------------------------------------------------------------
- def dispose_multiple_layers
- return if @m_layers == nil
- @m_layers.each {|layer| layer.dispose }
- end
- #--------------------------------------------------------------------------
- # ● Terminate
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_all_sprites
- goto_title
- end
- #--------------------------------------------------------------------------
- # ● Dispose Title Sprites
- #--------------------------------------------------------------------------
- def dispose_all_sprites
- return if @cursor == nil
- dispose_background1
- dispose_background2
- dispose_light
- dispose_multiple_layers
- if ANIMATED_SPRITE
- @object.bitmap.dispose
- @object.dispose
- @object_image.dispose
- end
- end
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- def update
- super
- update_background
- update_light
- update_object_animation
- update_multiple_layers
- terminate if Input.trigger?(:C)
- end
- #--------------------------------------------------------------------------
- # ● Update Multiple Layers
- #--------------------------------------------------------------------------
- def update_multiple_layers
- return if @m_layers == nil
- @m_layers.each {|layer| layer.update }
- end
- #--------------------------------------------------------------------------
- # ● Make Object bitmap
- #--------------------------------------------------------------------------
- def make_object_bitmap
- @object.bitmap.clear
- src_rect_back = Rect.new(@object_width * @object_index, 0,@object_width,@object_image.height)
- @object.bitmap.blt(0,0, @object_image, src_rect_back)
- end
- #--------------------------------------------------------------------------
- # ● Update Object Animation
- #--------------------------------------------------------------------------
- def update_object_animation
- return if !ANIMATED_SPRITE
- @object.opacity += 2
- @object_animation_speed += 1
- if @object_animation_speed > ANIMATED_SPRITE_SPEED
- @object_animation_speed = 0
- @object_index += 1
- @object_index = 0 if @object_index >= @object_frame_max
- make_object_bitmap
- end
- end
- #--------------------------------------------------------------------------
- # ● Execute Animation S
- #--------------------------------------------------------------------------
- def execute_animation_s
- @mx[2] += 1
- return if @mx[2] < 4
- @mx[2] = 0
- @mx[0] += 1
- case @mx[0]
- when 1..7; @mx[1] += 1
- when 8..14; @mx[1] -= 1
- else
- @mx[0] = 0
- @mx[1] = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● Update Background
- #--------------------------------------------------------------------------
- def update_background
- @sprite1.ox += RANDOM_PICTURES_SCROLL_SPEED[0]
- @sprite1.oy += RANDOM_PICTURES_SCROLL_SPEED[1]
- @sprite2.opacity += 2
- @sprite2.update
- return if RANDOM_PICTURES.size < 1
- @rand_title_duration -= 1
- if @rand_title_duration <= 0
- @sprite1.opacity -= 5 unless RANDOM_PICTURES.size < 2
- else
- @sprite1.opacity += 5
- end
- return if @sprite1.opacity != 0
- execute_random_picture
- end
- #--------------------------------------------------------------------------
- # ● Execute Random Picture
- #--------------------------------------------------------------------------
- def execute_random_picture(initial = false)
- @rand_title_duration = [[60 * RANDOM_PICTURES_DURATION, 9999].min, 60].max
- if @sprite1.bitmap != nil
- @sprite1.bitmap.dispose
- @sprite1.bitmap = nil
- end
- if RAMDOM_SELECTION
- rand_pic = rand(RANDOM_PICTURES.size)
- if rand_pic == @old_back_index
- rand_pic += 1
- rand_pic = 0 if rand_pic >= RANDOM_PICTURES.size
- end
- @old_back_index = rand_pic
- else
- @old_back_index += 1 unless initial
- @old_back_index = 0 if @old_back_index >= RANDOM_PICTURES.size
- end
- pic = RANDOM_PICTURES[@old_back_index]
- @sprite1.bitmap = Cache.gameover(pic) rescue nil
- @sprite1.bitmap = Cache.gameover("") if @sprite1.bitmap == nil
- end
- #--------------------------------------------------------------------------
- # ● Update Light
- #--------------------------------------------------------------------------
- def update_light
- return unless PARTICLE
- if @light_bitmap != nil
- for i in @light_bitmap
- i.update
- end
- end
- end
- end
- $mog_rgss3_animated_go_a = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement