Main Menu
  • Welcome to The RPG Maker Resource Kit.

Autotile Animation Speed Control

Started by modern algebra, September 28, 2008, 04:04:09 AM

0 Members and 1 Guest are viewing this topic.

modern algebra

Autotile Animation Speed Control
Version: 1.0
Author: modern algebra
Date: September 27, 2008

Version History




  • <Version 1.0> 09.27.2008 - Original Release

Description



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

Features


  • Autotiles can go faster or slower as you please
  • Precise control over autotile speed in frames
  • Can change the speed in-game

Screenshots

N/A

Instructions

See inside Header

Script




#==============================================================================
#  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




  • modern algebra


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.




Razielboy

Nice script i think i will use this one. Of course with credit to you lol.

Grafikal

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 :)

modern algebra

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.

Grafikal