Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Animated Options Script
#1
Animated Options Script V1.0 by Samo, The thief
June 18, 2007

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


The last year I had a great idea to improve the graphical appeareance of a game.
Let me see, there are battles, tileset,... MENUS!!! The Menus was the thing! After
a time, I saw Slipknot Animated_Sprite Script. This gave me agreat idea! Then I saw the Icon Command WIndow Script by Mewstrus! Great Idea too! So I decided to use both of them.
It was so hard to me to do a menu like that. But after one year I wanted to share this idea with you, and this script was born. It is really simple, it puts an icon before an option and when you have your cursor above it, it does an animation! All in one simple Script! You just create the icons, and your graphics will be improved! Really Good Feautures are included! Watch the below iNstructions for more details...


CODE:
-----
here it is:

Code:
=begin

-Animated Options Script V1.0 by Samo, The thief
@With Slipknot Animated Sprites Script

~What the heck is this script for?
The Options of any menu that uses a command window will have an icon with an animation
when you put the cursor above it.
It also supports resized windows, the ones that you need to scroll through, but always
be careful with this and use 32 multiples in any case.

~Really? How do I put it?
-Just put it above Main in a new slot.

~How do I use this damned thing?
Simple, just create the icons with the same name as the option like this:

NAME_#X where X is the frame number.

Now just see the Command window of an scene and try to see if there is an icon now.

~Something more to say?
Yes, it is a good feauture to add. Little Icons with animations in the menus.
They look Great! And it is sooo easy to do!


Enjoy!                        
                                    Samo, The thief

=end
  
class Window_Command < Window_Selectable
#-----------------------------------------------------------------------------
# @ Draw choice
#-----------------------------------------------------------------------------
MAX_FRAMES = 80     #How Many Frames will the animation take for max.
def draw_item(index, color)
   opacity = color == normal_color ? 255 : 128
   if ! @no_anims
     if FileTest.exist?("Graphics/Icons/" + @commands[index] + '_#1.png')
       rect = Rect.new(32, 32 * index, self.contents.width - 32, 32)
       frames = [@commands[index] + '_#1.png']
       for i in 1..MAX_FRAMES
         if FileTest.exist?("Graphics/Icons/" + @commands[index] + '_#' + i.to_s + '.png')
           frames.push(@commands[index] + '_#' + i.to_s + '.png')
         else
           break
         end
       end
       anim = Animated_Sprite.new(frames, 3, "icon")
       anim.freeze
       anim.x = self.x + 4 + 16
       anim.y = self.y + 32 * index + 19
       anim.z = self.z + 10
       @sprites[index] = anim
     else
       rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
     end
   else
     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
   end
   self.contents.font.color = color
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index])
end
#----------------------------------------------
   #--------------------------------------------------------------------------
  def initialize(width, commands, no_anims = false)
    @sprites = []
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @no_anims = no_anims
    refresh
    self.index = 0
    if @sprites[self.index] != nil
      @sprites[self.index].defreeze
    end
    indexes = [self.index - 1 < 0 ? @item_max - 1 : self.index - 1, self.index + 1 > @item_max - 1 ? 0 : self.index + 1]
    for i in indexes
      if @sprites[i] != nil
        @sprites[i].freeze
      end
    end
  end
  #---------------------------------
  def update
    super
    Animation.update
    if Input.repeat?(Input::UP) or Input.repeat?(Input::LEFT) or Input.repeat?(Input::RIGHT) or Input.repeat?(Input::DOWN) or Input.repeat?(Input::L) or Input.repeat?(Input::R)
      if @sprites[self.index] != nil
        @sprites[self.index].defreeze
      end
      indexes = [self.index - 1 < 0 ? @item_max - 1 : self.index - 1, self.index + 1 > @item_max - 1 ? 0 : self.index + 1]
      for i in indexes
        if @sprites[i] != nil
          @sprites[i].freeze
        end
      end
    end
  end
  #-----------------------
  def x=(value)
    last_x = value
    super(value)
    for sprite in @sprites
      if sprite != nil
        sprite.x = self.x + 4 + 16
      end
    end
  end
  #-----------------------
  def y=(value)
    last_y = value
    super(value)
    for i in 0...@sprites.size
      sprite = @sprites[i]
      if sprite != nil
        sprite.y = self.y + 32 * i + 19
      end
    end
  end
  #-------------------------------
  def z=(value)
    super(value)
    for sprite in @sprites
      if sprite != nil
        sprite.z = self.z + 10
      end
    end
  end
  #----------------------------------------
  def height=(value)
    super(value)
    self.oy = self.oy if @sprites != []
  end
  #------------------------------
  def index=(value)
    super(value)
    if @sprites[self.index] != nil
      @sprites[self.index].defreeze
    end
    indexes = [self.index - 1 < 0 ? @item_max - 1 : self.index - 1, self.index + 1 > @item_max - 1 ? 0 : self.index + 1]
    for i in indexes
      if @sprites[i] != nil
        @sprites[i].freeze
      end
    end
  end
  #----------------------------
  def oy=(value)
    super(value)
    indexes = (self.height - 32) / 32
    for sprite in @sprites
      sprite.opacity = 0
    end
    for i in (0 + self.oy / 32)...(0 + self.oy / 32 + indexes)
      sprite = @sprites[i]
      if sprite != nil
        sprite.opacity = 255
        if sprite != nil
          sprite.y = self.y + 32 * (i - (self.oy / 32)) + 19
        end
      end
    end
  end
  #-----------------------
  def dispose
    super
    for sprite in @sprites
      if sprite != nil
        sprite.dispose
      end
    end
  end
end


#============================================================
#  ¦ Animated Sprites ¦
#------------------------------------------------------------------------------
#   by Slipknot
#============================================================

class Animated_Sprite < Sprite
  #--------------------------------------------------------------------------
  # Attributes
  #--------------------------------------------------------------------------
  attr_accessor :frame, :delay
  attr_reader :bitmaps, :freeze
  #--------------------------------------------------------------------------
  #  bitmaps: are the names of the bitmaps used for each frame
  #  delay: time between frame changes, 10 = 1 sec
  #  type: icon, picture, character, battler, ...
  #--------------------------------------------------------------------------
  def initialize bitmaps, delay=10, type="picture"
    super()
    @method = RPG::Cache.method type
    self.bitmap = @method.call bitmaps[0]
    @bitmaps = bitmaps
    @delay = delay
    @frame = @count = 0
    @freeze = false
    Animation.push self
  end
  #--------------------------------------------------------------------------
  # Self dispose and delete
  #--------------------------------------------------------------------------
  def dispose
    Animation.delete self
    super
    bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # Hides and freeze, or show and defreeze
  #--------------------------------------------------------------------------
  def visible=(val)
    super(val)
    @freeze = (not val)
  end
  #--------------------------------------------------------------------------
  # Defreeze, play animation
  #--------------------------------------------------------------------------
  def defreeze
    @freeze = false
  end
  #--------------------------------------------------------------------------
  # Freeze, stop animation
  #--------------------------------------------------------------------------
  def freeze
    @freeze = true
  end
  #--------------------------------------------------------------------------
  # Return the number of frames
  #--------------------------------------------------------------------------
  def size
    @bitmaps.size
  end
  #--------------------------------------------------------------------------
  # Frame update
  #--------------------------------------------------------------------------
  def update
    return if @freeze or bitmaps.empty? or bitmaps.size == 1
    @count = (@count+1) % @delay
    return unless @count == 0
    @frame = (@frame+1) % bitmaps.size
    self.bitmap = @method.call bitmaps[@frame]
  end
end

module Animation
  #--------------------------------------------------------------------------
  # Data initialization
  #--------------------------------------------------------------------------
  @data = []
  #--------------------------------------------------------------------------
  # Update all animations
  #--------------------------------------------------------------------------
  def self.update
    return if @data.empty?
    @data.each do |o|
      o.update
    end
  end
  #--------------------------------------------------------------------------
  # Delete an animation
  #--------------------------------------------------------------------------
  def self.delete object
    @data.delete object
  end
  #--------------------------------------------------------------------------
  # Delete all the animations
  #--------------------------------------------------------------------------
  def self.clear
    return if @data.empty?
    @data.each do |o|
      o.dispose if not o.disposed?
    end
    @data.clear
  end
  #--------------------------------------------------------------------------
  # Freeze all the animations
  #--------------------------------------------------------------------------
  def self.freeze
    return if @data.empty?
    @data.each do |o|
      o.freeze
    end
  end
  #--------------------------------------------------------------------------
  # Defreeze all the animations
  #--------------------------------------------------------------------------
  def self.defreeze
    return if @data.empty?
    @data.each do |o|
      o.defreeze
    end
  end
  #--------------------------------------------------------------------------
  # Adds an animation
  #--------------------------------------------------------------------------
  def self.push object
    @data.push object
  end
end




INSTRUCTIONS:
-------------


~What the heck is this script for?
The Options of any menu that uses a command window will have an icon with an animation
when you put the cursor above it.
It also supports resized windows, the ones that you need to scroll through, but always
be careful with this and use 32 multiples in any case.

~Really? How do I put it?
-Just put it above Main in a new slot.

~How do I use this damned thing?
Simple, just create the icons with the same name as the option like this:

NAME_X where X is the frame number.

Now just see the Command window of an scene and try to see if there is an icon now.

~Something more to say?
Yes, it is a good feauture to add. Little Icons with animations in the menus.
They look Great! And it is sooo easy to do!



Enjoy the script and give me the credit.

Samo, the thief.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Modified Audio Encryption Script avatarmonkeykirby 0 2,264 07-28-2008, 01:00 PM
Last Post: avatarmonkeykirby
  Rotimikid's Enemy level Script ShockWave 0 2,355 08-24-2007, 01:00 PM
Last Post: ShockWave
  Script switch management GubiD 0 2,133 08-19-2007, 01:00 PM
Last Post: GubiD
  Nice game over script Moghunter 0 2,215 07-18-2007, 01:00 PM
Last Post: Moghunter
  Teleportation Script Digi 0 2,158 05-01-2007, 01:00 PM
Last Post: Digi
  Luck Script Darklord3652 0 2,153 04-10-2007, 01:00 PM
Last Post: Darklord3652
  GameOver Menu Script sasuke89 0 2,094 06-08-2006, 01:00 PM
Last Post: sasuke89
  Weapon Levelling Script GoldenShadow 0 2,102 07-05-2005, 01:00 PM
Last Post: GoldenShadow
  Ammo Script Dubealex 0 2,121 05-27-2005, 01:00 PM
Last Post: Dubealex
  Item Detail Script jackatrades 0 2,247 05-19-2005, 01:00 PM
Last Post: jackatrades



Users browsing this thread: