The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on September 28, 2008, 04:04:09 AM

Title: Autotile Animation Speed Control
Post by: modern algebra on September 28, 2008, 04:04:09 AM
Autotile Animation Speed Control
Version: 1.0
Author: modern algebra
Date: September 27, 2008

Version History



Description


Tired of your waterfall animating so slowly? This script allows you to set the speed that your A1 autotiles animate at.

Features


Screenshots

N/A

Instructions

See inside Header

Script


Code: [Select]
#==============================================================================
#  Autotile Animation Speed Control
#  Version: 1.0
#  Author: modern algebra (rmrk.net)
#  Date: September 27, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    Just paste this script between Materials and Main. To adjust default value
#   autotile frame count, go to line 40 and change the 30 there to the number
#   of frames you want it to wait between animating. Keep in mind that
#   there are 60 frames per second generally. You can also change the number
#   of frames waited in-game with the code:
#
#      $game_system.autotile_anim_frames = integer
#
#    If you use that code, however, you will need to go through a transfer
#   event before it will be applied, as calculations are only done when the map
#   is initialized. You can also transfer to the same map.
#==============================================================================
# ** Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased method - initialize
#    new public writer variable - autotile_anim_speed
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :autotile_anim_frames # Controls speed of autotiles
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_autotile_frm_upd_init_84n initialize
  def initialize
    # Run Original Method
    modalg_autotile_frm_upd_init_84n
    # Initialize Autotile variable
    @autotile_anim_frames = 30
  end
end
  
#==============================================================================
# ** Tilemap
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased methods - initialize, update
#==============================================================================
class Tilemap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_autotile_anim_frme_cntrl_init_93n5 initialize
  def initialize (viewport = nil)
    ma_autotile_anim_frme_cntrl_init_93n5 (viewport)
    # Calculate frame speed of update
    @frame_plus = 30.0 / $game_system.autotile_anim_frames.to_f
    # Initialize counting variables
    @anim_frames = 0.0
    @last_frame = 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_upd_frame_anim_autotiles_89r4b update
  def update
    # If counting variable has increased another 'frame'
    while @anim_frames >= @last_frame
      # Run Original method
      modalg_upd_frame_anim_autotiles_89r4b
      # Advance count variable
      @last_frame += 1
      if @last_frame == 30
        @anim_frames = 0.0
        @last_frame = 0
      end
    end
    # Advance false count variable
    @anim_frames += @frame_plus
  end
end

Credit




Support


Post here at rmrk.net for swiftest response

Known Compatibility Issues

No known compatibility issues at this point

Demo


Not really necessary. But, if requested, I will make one.

Author's Notes


The script aliases the update method of a hidden class, and I am not sure exactly how that method operates. I am acting under the assumption, however, that that method's only function is to update the autotiles. If this assumption is wrong, then the script could potentially cause some strange problems. If you notice anything on your tilemaps acting strangely, then please inform me of the problem and I will look into it.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Autotile Animation Speed Control
Post by: Razielboy on October 04, 2008, 10:29:22 PM
Nice script i think i will use this one. Of course with credit to you lol.
Title: Re: Autotile Animation Speed Control
Post by: Grafikal on November 26, 2008, 09:11:13 PM
Am I able to set a speed from the A1 waterfalls and the A1 water tiles? I would imagine having the water tide in and out so quickly would be in accurate, but having the waterfall tiles fall quickly would be logical. Lol. Just wondering if I'd be able to set them at different speeds or if it just controls all of the A1 tiles. Thanks :)
Title: Re: Autotile Animation Speed Control
Post by: modern algebra on November 27, 2008, 04:44:14 PM
I'm sorry, no :(

TileMap is a hidden class, so I don't really know what goes on in there. All I do now is make it space out how often it is updated, and all A1 tile are controlled in that update method. It's not a good way to write this script, but I don't know how to do it any other way :( sorry.
Title: Re: Autotile Animation Speed Control
Post by: Grafikal on November 28, 2008, 01:20:33 AM
No problem :)