Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Animation Resizer

Animation Resizer
Authors: game_guy
Version: 1.0
Type: Misc Add-on
Key Term: Misc Add-on


Introduction

Want to reduce or increase the size of certain animations? Don't wanna go  through all the tedious work to do it in the database? This script  can resize any animation for you.

Features

  • Increase animation size
  • Decrease animation size
  • Use only on specific animations
  • Use custom size value

Screenshots

N/A

Demo

N/A

Script

Code:
 

#===============================================================================

# Animation Resizer

# Author game_guy

# Version 1.0

#-------------------------------------------------------------------------------

# Intro:

# Want to reduce or increase the size of certain animations? Don't wanna go 

# through all the tedious work to do it in the database? This script 

# can resize any animation for you.

#

# Features:

# Increase animation size

# Decrease animation size

# Use only on specific animations

# Use custom size value

#

# Instructions:

# Note the animations also resize on events. 

# Go down to config below.

# Default_Increase - This is the default amount that is used to resize an

#   animation that isn't configured.

# Configure Sizes - This is the config for setting up sizes for specific 

#   animations only. If an animation isn't defined here then it uses

#   Default_Increase

#

# Don't want an animation resized on events? Simply use the following

# $game_system.anim_event = false

# Set it to true to have animations resized on events.

#

# Compatibility:

# Not tested with SDK.

# Should work where ever an animation is used.

#

# Credits:

# game_guy ~ For making it

# Jek ~ For requesting it

#===============================================================================

module GGHAN

  #==============================================

  # Config

  #==============================================

  # Default animation increase/decrease

  # Positive values = increase

  # Negative values = decrease

  Default_Increase = 0

  def self.zoom(id)

    case id

    #========================

    # Configure Sizes

    # Do:

    # when animation_id then return resize_amount_in_percent

    # Example:

    # when 67 then return 300

    # It increases the animation by 300 percent

    # Use negative values to decrease an animation.

    #

    # Note: When decreasing an animation size it can 

    # only decrease it as much as possible before making 

    # the animation dissappear. 

    #========================

    when 67 then return 300

    when 1 then return -90

    end

    return 0

  end

  #==============================================

  # End Config

  #==============================================

end

class Game_System

  attr_accessor :anim_event

  attr_accessor :is_event

  alias gg_init_anim_resize_lat initialize

  def initialize

    @anim_event = true

    @is_event = false

    gg_init_anim_resize_lat

  end

end

module RPG

  class Sprite < ::Sprite

    def animation_set_sprites(sprites, cell_data, position)

      for i in 0..15

        sprite = sprites[i]

        pattern = cell_data[i, 0]

        if sprite == nil or pattern == nil or pattern == -1

          sprite.visible = false if sprite != nil

          next

        end

        sprite.visible = true

        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)

        if position == 3

          if self.viewport != nil

            sprite.x = self.viewport.rect.width / 2

            sprite.y = self.viewport.rect.height - 160

          else

            sprite.x = 320

            sprite.y = 240

          end

        else

          sprite.x = self.x - self.ox + self.src_rect.width / 2

          sprite.y = self.y - self.oy + self.src_rect.height / 2

          sprite.y -= self.src_rect.height / 4 if position == 0

          sprite.y += self.src_rect.height / 4 if position == 2

        end

        sprite.x += cell_data[i, 1]

        sprite.y += cell_data[i, 2]

        sprite.z = 2000

        sprite.ox = 96

        sprite.oy = 96

        if $scene.is_a?(Scene_Map) && $game_system.anim_event

          zoom = GGHAN.zoom(@_animation.id)

          if zoom < 0

            c = -zoom

            if cell_data[i, 3] <= c

              c = cell_data[i, 3] - 1

              cc = cell_data[i, 3] - c

              #p cc.to_s + " IF " + cell_data[i, 3].to_s

            else

              cc = cell_data[i, 3] - c

              #p cc.to_s + " ELSE " + cell_data[i, 3].to_s

            end

          else

            cc = cell_data[i, 3] + zoom

          end

          sprite.zoom_x = cc / 100.0

          sprite.zoom_y = cc / 100.0

        elsif $scene.is_a?(Scene_Map) && !$game_system.anim_event

          cc = cell_data[i, 3]

          sprite.zoom_x = cc / 100.0

          sprite.zoom_y = cc / 100.0

        elsif $scene.is_a?(Scene_Battle)

          zoom = GGHAN.zoom(@_animation.id)

          cc = cell_data[i, 3] + zoom

          sprite.zoom_x = cc / 100.0

          sprite.zoom_y = cc / 100.0

        end

        sprite.angle = cell_data[i, 4]

        sprite.mirror = (cell_data[i, 5] == 1)

        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0

        sprite.blend_type = cell_data[i, 7]

      end

    end

  end

end

 

 

Instructions

In the script.
Probably place below everything and above main.
Read all instructions carefully.

Compatibility

Not tested with SDK.

Credits and Thanks

  • game_guy ~ For making it
  • Jek ~ For requesting it

Author's Notes

Enjoy!
 

Atoa

Member

Code:
   def self.zoom(id)

     case id

     #========================

     # Configure Sizes

     # Do:

     # when animation_id then return resize_amount_in_percent

     # Example:

     # when 67 then return 300

     # It increases the animation by 300 percent

     # Use negative values to decrease an animation.

     #

     # Note: When decreasing an animation size it can

     # only decrease it as much as possible before making

     # the animation dissappear.

     #========================

     when 67 then return 300

     when 1 then return -90

     end

     return 0

   end
I don't like this "case strcuture" for settings. I normally make an array or hash. also i don't undestand why you've made an method for this.

Something like this would have the same effect:
Code:
module GGHAN

  Animation_Zoom = {} 

 

  Default_Zoom = 0

 

  Animation_Zoom[Anim ID] = Zoom_Value

end

Also the zoom isn't pefect. you resize de sprites, but not change their position.

Let's say we have this animation.
Novo(a)%20Imagem%20de%20Bitmap2_2_1.PNG

Note that the fireballs touch each other

With the zoom they're resized, but their position don't change.
Novo(a)%20Imagem%20de%20Bitmap2_2_2.PNG


The right would be something like this:
Novo(a)%20Imagem%20de%20Bitmap2_2_3.PNG

The sprite are zoomed but still touching each other

I've made an camera zoom script for my battle system, this is how i've made on it:
Code:
      sprite.x += cell_data[i, 1] * zoom_value

      sprite.y += cell_data[i, 2] * zoom_value

      sprite.ox = 96

      sprite.oy = 96

      sprite.zoom_x = (cell_data[i, 3] / 100.0) * zoom_value

      sprite.zoom_y = (cell_data[i, 3] / 100.0) * zoom_value

So you could make your conditions before that to set the zoom_value.
Something like this for the RPG::Sprite:

Code:
 

class RPG::Sprite

  def animation_set_sprites(sprites, cell_data, position)

    for i in 0..15

      sprite = sprites[i]

      pattern = cell_data[i, 0]

      if sprite == nil or pattern == nil or pattern == -1

        sprite.visible = false if sprite != nil

        next

      end

      sprite.visible = true

      sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)

      if position == 3

        if self.viewport != nil

          sprite.x = self.viewport.rect.width / 2

          sprite.y = self.viewport.rect.height - 160

        else

          sprite.x = 320

          sprite.y = 240

        end

      else

        sprite.x = self.x - self.ox + self.src_rect.width / 2

        sprite.y = self.y - self.oy + self.src_rect.height / 2

        sprite.y -= self.src_rect.height / 4 if position == 0

        sprite.y += self.src_rect.height / 4 if position == 2

      end

      unless $scene.is_a?(Scene_Map) and not $game_system.anim_event

        zoom_value = 1.0

      else $scene.is_a?(Scene_Battle)

       zoom_value = GGHAN::Animation_Zoom[@_animation.id].nil? ?  GGHAN::Default_Zoom / 100.0 : GGHAN::Animation_Zoom[@_animation.id] / 100.0

      end

      sprite.x += cell_data[i, 1] * zoom_value

      sprite.y += cell_data[i, 2] * zoom_value

      sprite.ox = 96

      sprite.oy = 96

      sprite.zoom_x = (cell_data[i, 3] / 100.0) * zoom_value

      sprite.zoom_y = (cell_data[i, 3] / 100.0) * zoom_value

      sprite.angle = cell_data[i, 4]

      sprite.mirror = (cell_data[i, 5] == 1)

      sprite.opacity = cell_data[i, 6] * self.opacity / 255.0

      sprite.blend_type = cell_data[i, 7]

    end

  end

end
 
Good points on the positioning. I'll look into your code see if I can fix that.

And the case structure/method is how I code. Sure your way is cleaner but the amount of configuration users have to put in is practically the same. My way is how I learned to do it and I intent on keeping it. Sorry if it bugs you.
 

Atoa

Member

My way is how I learned to do it and I intent on keeping it.
I must say that it's quite odd...
you learned something in an way, then learn an better way to do the same thing... why then keep doing things on the old way? .-.
Well the script is yours .-.
 
Bad habits I guess. I know its a better way with arrays but just a habit. However I'm gonna start breaking out of it. I already implemented your way into the config but I still need to add the repositioning and stuff.

Thanks ^_^
 
This script is very cool, hope you can fix the repositioning stuff, if I find something useful for that I'll edit this post.

Greetings!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top