[XP] Transition Pack Add-On

Started by ForeverZer0, December 02, 2010, 11:23:03 pm

Previous topic - Next topic

ForeverZer0

December 02, 2010, 11:23:03 pm Last Edit: December 10, 2010, 10:32:52 pm by ForeverZer0
Transition Pack Add-Ons
Authors: ForeverZer0
Version: 1.0
Type: Custom Transitions
Key Term: Misc Add-on



Introduction
This is a thread to post additional transition to use with Fantasist's Transition Pack, which can be found here: http://forum.chaos-project.com/index.php/topic,1390.0.html

I would normally post this in the thread for the script, or submit it to see if it could be added, but the original auhor of the script is no longer active on the forum.



Intructions
Adding them is easy, just follow these steps:

  • Copy and paste the code for the transition you would like to add to the original script.
  • Find the "call_effect" method near the top of the script.
  • Create a new line before the "end" in the case statements ( "when NUMBER then .... ")
  • Follow the pattern, and add your own line, like this:
when NUMBER then METHOD_NAME

  • Repeat this process in the second part of the "call_effect" method, but this time add a "(*args)" to the end of the line:
    when NUMBER then METHOD_NAME(*args)

    • You can now call the method with the number that you defined in the lines you added!




    Adding Sound Effects
    To add a sound effect, simply add a line into the desired method like this.

    $game_system.se_play(RPG::AudioFile.new('SE_FILENAME', VOLUME, PITCH))


    SE_FILENAME: Name of a file in the Audio/SE directory. Must be a string (within '  ' or "  ").
    VOLUME: Desired volume to use for sound effect. (0 - 100)
    PITCH: Desired pitch to use for sound effect. (50 - 150)

    It is important to pay attention as to where you place the line.
    Placing it in the middle of an iteration will cause the game to attempt to play the sound effect many times per second (usually). If you are in doubt, it will usually be okay to simply place it at the beginning of the method, or just experiment around to see what best suits your needs.


    Submission
    I would be happy to include methods created by others to this thread. If you have created a custom transition and would like to submit, please do so, using this template:


    [hr]
    [b][u][color=green]<NAME OF EFFECT>[/color][/u][/b]

    [spoiler][quote]<CODE FOR THE METHOD GOES HERE, BUT USE CODE TAGS>[/quote][/spoiler]

    <SMALL EXPLANATION OF WHAT IT DOES>

    [list]
    [*][b]<ARGUMENT1:>[/b] <EXPLAIN WHAT THE FIRST ARGUMENT DOES>
    [*][b]<ARGUMENT2:>[/b] <EXPLAIN WHAT THE SECOND ARGUMENT DOES>
    [*]<AND SO ON...>
    [/list]



    Tile Sprite Method

    Spoiler: ShowHide

     def tile_sprites(tilesize)
       tiles = []
       # Iterate through main sprite, creating sprites for each square.
       (0...@sprite.bitmap.width / tilesize).each {|x|
         (0...@sprite.bitmap.height / tilesize).each {|y|
           sprite = Sprite.new
           sprite.x, sprite.y = x*tilesize, y*tilesize
           sprite.bitmap = Bitmap.new(tilesize, tilesize)
           rect = Rect.new(sprite.x, sprite.y, tilesize, tilesize)
           sprite.bitmap.blt(0, 0, @sprite.bitmap, rect)
           tiles.push(sprite)
         }
       }
       @sprite.opacity = 0
       return tiles
     end


    This is not a transition, but is a required method for some of them. The transitions that require it will have a note stating that they do in the description.


    Double Zoom

    Spoiler: ShowHide

     def double_zoom(frames = 30, zoom1 = 12, zoom2 = 32)
       # Calculate the stages. Account for final zoom being longer.
       stage3 = (frames * (zoom1.to_f / zoom2)).round
       stages = [(frames - stage3) / 2, (frames - stage3) / 2, stage3]
       # Calculate the zoom rates to apply each frame, for each stage.
       zoom_rates, opacity_rate = [zoom1-1, -zoom1+1, zoom2], (255 / frames.to_f)
       zoom_rates.each_index {|i| zoom_rates[i] /= stages[i].to_f }
       # Initialize local variable to keep track of current stage being executed.
       current_stage = 0
       3.times do
         # Iterate each stage, using the calculated rates for each one.
         stages[current_stage].times do
           @sprite.zoom_x += zoom_rates[current_stage]
           @sprite.zoom_y += zoom_rates[current_stage]
           @sprite.opacity -= opacity_rate
           Graphics.update
         end
         current_stage += 1
       end
     end


    Zooms in, then back out, then in again. Both zoom levels are configurable.


    • FRAMES: Total number of frames the transition will take.
    • ZOOM1: The target zoom level of the first zoom.
    • ZOOM2: The target zoom of the second zoom.



    Retro Final Fantasy

    Spoiler: ShowHide

     def ff_IV_style(zoom1 = 1.2, zoom2 = 32)
       # Set number of frames and zoom rates for each stage.
       stages = [4, 4, 4, 4, 20]
       zooms = [zoom1, -zoom1, zoom1, -zoom1, zoom2]
       zooms.each_index {|i| zooms[i] /= stages[i].to_f }
       current_stage = 0
       5.times do
         # Begin processing.
         stages[current_stage].times do
           @sprite.zoom_x += zooms[current_stage]
           @sprite.zoom_y += zooms[current_stage]
           @sprite.opacity -= 12 if current_stage == 4
           Graphics.update
         end
         # Increase current stage.
         current_stage += 1
       end
     end


    Classic transition used in early SNES Final Fantasy games. Similiar to the double zoom, does a quick double stammer, then zooms in all the way very quickly.


    • ZOOM1: Level of zoom used in the initial stutter.
    • ZOOM2: Level of zoom for the final zoom.



    Downward Spiral

    Spoiler: ShowHide

     def downward_spiral(frames = 40, rotation_speed = 15)
       # Calculate the zoom to subtract each frame.
       zoom, opacity = 1.0 / frames, 128.0 / frames
       frames.times do
         # Begin processing.
         @sprite.zoom_x -= zoom
         @sprite.zoom_y -= zoom
         @sprite.opacity -= opacity
         @sprite.angle += rotation_speed
         Graphics.update
       end
     end


    Screen rotates as it falls fading away.


    • FRAMES: Total number of frames the transition takes to fall away completely.
    • ROTATION SPEED: Defines how fast the screen rotates in degrees.



    Blackhole

    Spoiler: ShowHide

     def blackhole(speed = 4, tilesize = 12, source = [320, 240])
       # Initialize squares array to hold each sprite.
       tiles = tile_sprites(tilesize)
       # Make each sprite slightly smaller than full size.
       tiles.each {|tile| tile.zoom_x = tile.zoom_y = 0.85 }
       # Begin looping until all sprites have been disposed.
       until tiles.compact == []
         # Iterate each tiles.
         tiles.each_index {|i|
           next if tiles[i] == nil
           # Get distance of this sprite from the source for each axis.
           sx = source[0] - tiles[i].x
           sy = source[1] - tiles[i].y
           # Calculate total distance and set base speed for each axis.
           dist = Math.hypot(sx, sy).to_f
           move_x = (dist / (sx == 0 ? 1 : sx))
           move_y = (dist / (sy == 0 ? 1 : sy))
           # Add a little randomness to the mix.
           move_x += move_x < 0 ? -rand(speed) : rand(speed)
           move_y += move_y < 0 ? -rand(speed) : rand(speed)
           # Apply movement.
           tiles[i].x += move_x
           tiles[i].y += move_y
           tiles[i].angle += rand(20)
           # If tile is within its own size from source, dispose it.
           if sx.abs <= tilesize && sy.abs <= tilesize
              tiles[i].bitmap.dispose
              tiles[i] = tiles[i].dispose
           end
         }
         Graphics.update
       end
     end


    Screen is broken into small pieces, which are then sucked into a specific point on the screen.


    • SPEED: Defines how fast the pieces move to the SOURCE.
    • TILESIZE: Size, in pixels, of the width and height that the tiles that the screen is broken into.
    • SOURCE: A two element array that defines the X and Y, in pixels, of the origin point of the "blackhole".

    REQUIRES "tile_sprite" METHOD. (see above)



    Wave Distort

    Spoiler: ShowHide

     def wave_distort(frames = 60, direction = 2, power = 0.4)
       radius, tiles = 0, tile_sprites(16)
       # Define starting point for zoom, depending on direction.
       origin = case direction
       when 2 then [@sprite.bitmap.width / 2, @sprite.bitmap.height]
       when 4 then [0, @sprite.bitmap.height / 2]
       when 6 then [@sprite.bitmap.width, @sprite.bitmap.height / 2]
       when 8 then [@sprite.bitmap.width / 2, 0]
       end
       # Initialize local variable for the rate the radius will increase.
       rate = Math.hypot(@sprite.bitmap.width, @sprite.bitmap.height) / frames
       # Begin processing.
       frames.times do
         # Iterate through each tile, calculating distance from focal point.
         tiles.each {|tile|
           dist = Math.hypot((origin[0] - tile.x), (origin[1] - tile.y))
           # Zoom tile on one axis, depending on direction.
           next if radius < dist
           [4, 6].include?(direction) ? tile.zoom_x += power : tile.zoom_y += power
         }
         # Increase radius for next iteration.
         radius += rate
         Graphics.update
       end
       # Dispose each bitmap and sprite used for the tiles.
       tiles.each {|tile| tile.bitmap.dispose; tile.dispose }
     end


    Causes the screen to distort in a "wave" effect.


    • FRAMES: Total number of frames the transition will take.
    • DIRECTION: Corresponds to the direction the wave comes from. (2 = down, 4 = left, 6 = right, 8 = up)
    • POWER: The level of the distort. Should be a small number between 0 and 1.


    REQUIRES "tile_sprite" METHOD. (see above)



    Radial Break

    Spoiler: ShowHide
      
     def radial_break(frames = 60, tilesize = 16, direction = 4, speed = 9)
       radius, tiles = 0, tile_sprites(tilesize)
       # Define starting point for zoom, depending on direction.
       origin = case direction
       when 2 then [@sprite.bitmap.width / 2, @sprite.bitmap.height]
       when 4 then [0, @sprite.bitmap.height / 2]
       when 6 then [@sprite.bitmap.width, @sprite.bitmap.height / 2]
       when 8 then [@sprite.bitmap.width / 2, 0]
       end
       # Initialize local variable for the rate the radius will increase.
       rate = Math.hypot(@sprite.bitmap.width, @sprite.bitmap.height) / frames
       # Begin processing.
       until tiles == []
         tiles.compact!
         # Iterate through each tile, calculating distance from focal point.
         tiles.each_index {|i|
           # Get distance of this sprite from the source for each axis.
           sx = origin[0] - tiles[i].x
           sy = origin[1] - tiles[i].y
           dist = Math.hypot(sx, sy).to_f
           # Zoom tile on one axis, depending on direction.
           next if radius < dist
           # Calculate total distance and set base speed for each axis.
           move_x = (dist / (sx == 0 ? 1 : sx))
           move_y = (dist / (sy == 0 ? 1 : sy))
           # Add a little randomness to the mix.
           move_x += move_x < 0 ? -rand(speed) : rand(speed)
           move_y += move_y < 0 ? -rand(speed) : rand(speed)
           # Half distance of one axis, depending on rate.
           [2, 8].include?(direction) ? move_x /= 2 : move_y /= 2
           # Apply movement.
           tiles[i].x += move_x
           tiles[i].y += move_y
           angle = (tiles[i].object_id % 2 == 0) ? rand(25) : -rand(25)
           tiles[i].angle += (angle + 5)
           # If tile is within its own size from source, dispose it.
           if sx.abs <= tilesize || sy.abs <= tilesize
              tiles[i].bitmap.dispose
              tiles[i] = tiles[i].dispose
           end
         }
         # Increase radius for next iteration.
         radius += rate / 2
         Graphics.update
       end
     end


    Screen breaks into hundreds of pieces in a wave effect, and then move towards the source of the wave in a random pattern.


    • FRAMES: Number of frames the transition will take. (approx.)
    • TILESIZE: Size, in pixels, of the width and height that the tiles that the screen is broken into.
    • DIRECTION: Corresponds to the direction the wave comes from. (2 = down, 4 = left, 6 = right, 8 = up)
    • SPEED: Speed at which the pieces move.

    REQUIRES "tile_sprite" METHOD. (see above)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

You forgot to fill out the topic header. D:
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

You want me to format this for the database?

I didn't really "forget" to do it, I just wasn't sure if this would be the type of thing to go to the database. I shall make it look it nice for you though...  ;)
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Fantasist

Awesome, man! :D  *levels up*
I've edited the first post in my topic to point here. Nice job :)
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




ForeverZer0

Thanks!  :haha:

I would have asked you if you wanted to add them in to yours, but you haven't been around. You still can if you like, or a link to this would be sufficient as well.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

It's a "plugin" for FTS's script after all. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Fantasist

I've linked to this topic in my topic. Better this way, I won't stay for long.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




MikePjr

Lol, you could have at least mentioned how i requested the retro final fantasy one >_<
And how do i add the definition?

ForeverZer0

Quote from: Instructions from the top of the page.
Adding them is easy, just follow these steps:

Copy and paste the code for the transition you would like to add to the original script.
Find the "call_effect" method near the top of the script.
Create a new line before the "end" in the case statements ( "when NUMBER then .... ")
Follow the pattern, and add your own line, like this:
Code:
when NUMBER then METHOD_NAME
Repeat this process in the second part of the "call_effect" method, but this time add a "(*args)" to the end of the line:
Code:
when NUMBER then METHOD_NAME(*args)
You can now call the method with the number that you defined in the lines you added!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Mimi Chan

Oh nice new transition *.*

I wonder if its possible to put a random background behind instead of just black screen? (think loading screen) and maybe put SE per kind of transition o.oa
I would love to hear an exploding sound with some of the transition *.*
What's a sig?

ForeverZer0

December 10, 2010, 08:19:43 pm #10 Last Edit: December 10, 2010, 10:33:47 pm by ForeverZer0
I made an edit to the "Radial Break" effect. It does nothing new, but is a little more efficient since I removed a few lines of code that were in there needlessly. I had accidentally made the same calculations twice for no reason.


EDIT: Okay, made an edit to the post this time. Added instructions on how to add sound effects.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Mimi Chan

Oh nice sound effects *.*

Though it's kinda hard to time the sound effect with transition, specially when using multiple SE O.O
How about an option of playing animation too? It's easier to set up SE there ^^;
What's a sig?