Jump to content
  • entries
    65
  • comments
    526
  • views
    66,809

Frame Buffer Battle Swirl

Kayzee

27,692 views

Wowsers, been a while huh? Anyway here is something I did the other day... a fancy Final Fantasy 7-9 style frame buffer battle swirl effect! All sorts of cool effects could be done with a frame buffer.

 

 

 

module FrameBuffer    class << self    attr_reader :viewport  end    def self.set_start_frame(frame = Graphics.snap_to_bitmap)    @start_frame = frame  end    def self.start(frames = 1, xfocus = nil, yfocus = nil, viewport_z = 10000)    dispose unless disposed?    this_frame = @start_frame || Graphics.snap_to_bitmap    @start_frame = nil    @buffer = []    @viewport = Viewport.new    @viewport.z = viewport_z        frames.times do      sprite = Sprite.new(@viewport)      sprite.bitmap = this_frame.clone      sprite.x = xfocus || Graphics.width / 2      sprite.y = yfocus  || Graphics.height / 2      sprite.ox = xfocus || Graphics.width / 2      sprite.oy = yfocus || Graphics.height / 2      @buffer.push(sprite)    end    this_frame.dispose  end    def self.change_focus(x, y)    @buffer.each do |sprite|      sprite.x = x      sprite.y = y      sprite.ox = x      sprite.oy = y    end  end    def self.dispose    return if disposed?    @buffer.each {|sprite| sprite.dispose}    @viewport.dispose if @viewport    @buffer = nil    @viewport = nil  end    def self.disposed?    !@buffer  end    # Deletes the oldest frame bitmaps and shuffles all the bitmaps down  # replacing the first frame with a fresh snap shot  def self.cycle    return if disposed?    @buffer[-1].bitmap.dispose    @buffer.each_index do |i|      next if i == 0      @buffer[i].bitmap = @buffer[i - 1].bitmap    end    @buffer[0].bitmap = Graphics.snap_to_bitmap  end    # Set's all the frame buffer sprites to use a fresh snapshot  def self.refresh    this_frame = Graphics.snap_to_bitmap    @buffer.each do |sprite|      sprite.bitmap.dispose unless sprite.bitmap.disposed?      sprite.bitmap = this_frame #.clone    end    #this_frame.dispose  end    def self.[](num)    return nil if disposed?    return @buffer[num]  end  endclass Game_Temp  attr_accessor :special_battle_swirlendclass Scene_Map < Scene_Base  #--------------------------------------------------------------------------  # * Preprocessing for Battle Screen Transition  #--------------------------------------------------------------------------  def pre_battle_scene    Graphics.update    Graphics.freeze        if $game_temp.special_battle_swirl      start_boss_swirl      $game_temp.special_battle_swirl = nil    else      start_battle_swirl    end        @spriteset.dispose_characters    BattleManager.save_bgm_and_bgs    BattleManager.play_battle_bgm    Sound.play_battle_start  end  def start_battle_swirl    FrameBuffer.start(3, $game_player.screen_x, $game_player.screen_y)        FrameBuffer[0].z = 0    FrameBuffer[0].zoom_x = 1.01    FrameBuffer[0].zoom_y = 1.01    FrameBuffer[0].opacity = 225    FrameBuffer[0].angle = 0    FrameBuffer[0].blend_type = 0        FrameBuffer[1].z = 1    FrameBuffer[1].zoom_x = 0.88    FrameBuffer[1].zoom_y = 0.99    FrameBuffer[1].opacity = 34    FrameBuffer[1].angle = 6    FrameBuffer[1].blend_type = 1        FrameBuffer[2].z = 2    FrameBuffer[2].zoom_x = 1.04    FrameBuffer[2].zoom_y = 1.04    FrameBuffer[2].opacity = 128    FrameBuffer[2].angle = 355    FrameBuffer[2].blend_type = 0  end    def start_boss_swirl    FrameBuffer.start(4, $game_player.screen_x, $game_player.screen_y)    FrameBuffer[0].z = 0    FrameBuffer[0].zoom_x = 1.01    FrameBuffer[0].zoom_y = 1.01    FrameBuffer[0].opacity = 235    FrameBuffer[0].angle = 0    FrameBuffer[0].blend_type = 0        FrameBuffer[1].z = 1    FrameBuffer[1].zoom_x = 0.95    FrameBuffer[1].zoom_y = 0.93    FrameBuffer[1].opacity = 128    FrameBuffer[1].angle = 353    FrameBuffer[1].blend_type = 0       FrameBuffer[2].z = 2    FrameBuffer[2].zoom_x = 1.3    FrameBuffer[2].zoom_y = 1.3    FrameBuffer[2].opacity = 12    FrameBuffer[2].angle =  12    FrameBuffer[2].blend_type = 2        FrameBuffer[3].z = 3    FrameBuffer[3].zoom_x = 1.02    FrameBuffer[3].zoom_y = 1.02    FrameBuffer[3].opacity = 24    FrameBuffer[3].angle = 356    FrameBuffer[3].blend_type = 1  end    #--------------------------------------------------------------------------  # * Execute Pre-Battle Transition  #--------------------------------------------------------------------------  def perform_battle_transition    Graphics.transition(1)    (0..60).each do |i|      Graphics.brightness = 255      FrameBuffer.refresh      Graphics.frame_reset      Graphics.brightness = 255 - (255 * ((i - 40) / 20.0)) if i > 40      Graphics.update    end    FrameBuffer.dispose    Graphics.freeze  end  end

 

Edit: I updated the above with a more up to date version with a slightly different effect and the ability to set $game_temp.special_battle_swirl to true for an alternative swirl for bosses. For completeness sake I am putting a version of start_battle_swirl that emulates the old effect here:

 

 

 

  def start_battle_swirl    FrameBuffer.start(3)        FrameBuffer[0].z = 0    FrameBuffer[0].zoom_x = 1    FrameBuffer[0].zoom_y = 1    FrameBuffer[0].opacity = 235    FrameBuffer[0].angle = 0    FrameBuffer[0].blend_type = 0        FrameBuffer[1].z = 1    FrameBuffer[1].zoom_x = 1.01    FrameBuffer[1].zoom_y = 1.01    FrameBuffer[1].opacity = 128    FrameBuffer[1].angle = 359    FrameBuffer[1].blend_type = 0       FrameBuffer[2].z = 2    FrameBuffer[2].zoom_x = 0.8    FrameBuffer[2].zoom_y = 0.9    FrameBuffer[2].opacity = 12    FrameBuffer[2].angle = 12    FrameBuffer[2].blend_type = 1  end

 



3 Comments


Recommended Comments

Had a quick looksy and wow that's really cool. Nice one :D

Thankies! I did a lot of fiddling to wind up with that particular effect... there are tons of different ways to tweak things that can really effect the outcome.

Share this comment


Link to comment

I'll have to have a play with it sometime. I'm always looking for cool new ways to enhance the game, if only small things like this - the little things matter!

Share this comment


Link to comment
×