#===============================================================================
# New Animation Methods for Pokemon Sprites
#===============================================================================
#
# Supports both animated, and static sprites.
# Does not support the usage of GIFs.
# Any one frame of sprite needs to be of equal width and height.
# All sprites need to be in 1*1 px resolution.
# Use dragonnite's(Lucy's) GIF to PNG converter to properly format your sprites.
#
# Allows the use of custom looping points.
#
#
# Made a muk ton more understandable, around specific classes, by TragicSolitude!
# LRN2DOCUMENT, KLEIN. IT DOESN'T MATTER IF YOU DON'T EXPECT PEOPLE TO EDIT SOMETHING
# GOT DAMN. (AUTISTIC SCREECHING)
#
=begin
How to use this script, simply:
Choose the class to use based on the behavior you want the animated bitmap to have:
Play once, manually loop: AnimatedBitmapWrapperAnim
Loop automatically: AnimatedBitmapWrapper
Create a variable to hold the instanced class, and pass a file to the class you
want. E.g., we want a looping bitmap. So we'd call:
animatedBitmap = AnimatedBitmapWrapper.new(bitmapToUse)
Then set any values we want by using:
animatedBitmap.setLoop(0,animatedBitmap.length)
Or anything else. (Check the documentation for values you can set that affect
how the bitmap plays/acts/etc)
Then, when we want the bitmap to play, we call the update() method in a loop:
loop do
animatedBitmap.update()
end
And that will play our looping bitmap!
=end
#===============================================================================
#=begin
class Sprite
def skew(angle=90)
angle=angle*(Math::PI/180)
return false if !self.bitmap
bitmap=self.bitmap
rect=Rect.new(0,0,bitmap.width,bitmap.height)
width=rect.width+(rect.height/Math.tan(angle))
self.bitmap=Bitmap.new(width,rect.height)
for i in 0...rect.height
y=rect.height-i
x=i/Math.tan(angle)
self.bitmap.blt(x+rect.x,y+rect.y,bitmap,Rect.new(0,y,rect.width,1))
end
end
def skew2(angle=90)
angle=angle*(Math::PI/180)
return false if !self.bitmap
bitmap=self.bitmap
rect=Rect.new(0,0,bitmap.width,bitmap.height)
width=rect.width+(rect.height/Math.tan(angle))+200
self.bitmap=Bitmap.new(width,rect.height)
for i in 0...rect.height
y=rect.height-i
x=i/Math.tan(angle)
self.bitmap.blt(-x+rect.x,y+rect.y,bitmap,Rect.new(-120,y,rect.width+120,1))
end
end
end
=begin
This class is used for when we want a bitmap that will loop indefinitely, around
specific points. Whether start/finish (default) or around points passed to it
through its methods.
=end
class AnimatedBitmapWrapper
attr_reader :width
attr_reader :height
attr_reader :totalFrames
attr_reader :animationFrames
attr_reader :currentIndex
attr_reader :scale
#Called when creating a new instance of AnimatedBitmapWrapper
def initialize(file,scale=1,twoframe=false)
raise "filename is nil" if file==nil
@scale = scale
@width = 0
@height = 0
@frame = 0
@frames = 2
@direction = +1
@twoframe = twoframe
@animationFinish = false
@totalFrames = 0
@currentIndex = 0
@speed = 1
# 0 - not moving at all
# 1 - normal speed
# 2 - medium speed
# 3 - slow speed
@bitmapFile=BitmapCache.load_bitmap(file)
# initializes full Pokemon bitmap
@bitmap=Bitmap.new(@bitmapFile.width,@bitmapFile.height)
@bitmap.blt(0,0,@bitmapFile,Rect.new(0,0,@bitmapFile.width,@bitmapFile.height))
@
[email protected]*@scale
@
[email protected]*@scale
#Tragic #ADD [01/29/2018]
#A variable that lets us track how many loops we've gone through.
@loopCount = 0
@
[email protected]/@bitmap.height
@animationFrames=@totalFrames*@frames
# calculates total number of frames
@loop_points=[0,@totalFrames]
# first value is start, second is end
@actualBitmap=Bitmap.new(@width,@height)
@actualBitmap.clear
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
#Methods that allow us to get specific information about our instanced class.
#The length (in frames) of a wrapped bitmap.
def length; @totalFrames; end
#A method that returns a boolean telling us if the bitmap has been disposed.
def disposed?; @actualBitmap.disposed?; end
#A method that forces the bitmap to dispose.
def dispose; @actualBitmap.dispose; end
#A method that creates a copy of the wrapped bitmap that can be manipulated
#seperately from the original.
def copy; @actualBitmap.clone; end
#A method that returns the wrapped bitmap.
def bitmap; @actualBitmap; end
#A method that allows us to change the bitmap this instanced class is using.
def bitmap=(val); @actualBitmap=val; end
#I think this method allows us to do something for each frame in the file passed.
def each; end
#A method that returns a specific "frame" of the bitmap at the position passed.
def alterBitmap(index); return @strip[index]; end
#Tragic #ADD [01/28/2018]
#A method that returns the current amount of loop counts
def loopCount; return @loopCount; end
#I'm not entirely sure what this method does, tbh.
def prepareStrip
@strip=[]
for i in 0...@totalFrames
bitmap=Bitmap.new(@width,@height)
bitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmapFile,Rect.new((@width/@scale)*i,0,@width/@scale,@height/@scale))
@strip.push(bitmap)
end
end
#I'm not entirely sure what this method does, tbh.
def compileStrip
@bitmap.clear
for i in
[email protected]
@bitmap.stretch_blt(Rect.new((@width/@scale)*i,0,@width/@scale,@height/@scale),@strip
,Rect.new(0,0,@width,@height))
end
end
#This method allows us to reverse the current direction that the animated bitmap
#is playing in.
def reverse
if @direction > 0
@direction=-1
elsif @direction < 0
@direction=+1
end
end
#This method allows us to set specific loop points for the reel that the update
#method will play around. (The default values are start and end)
def setLoop(start, finish)
@loop_points=[start,finish]
end
#This method allows us to change the speed that the wrapper will play the reel.
def setSpeed(value)
@speed=value
end
#This method makes the bitmap display the specific frame that is passed.
#Accepts: "last", "middle", or "start". Any other string will default to start.
#Accepts: ints for exact position.
#Tragic #EDIT [05/02/2018]
#-Modified how this method handles strings to allow us to have a "middle" option.
#-Raises an error if using anything other than first three strings listed.
def toFrame(frame)
if frame.is_a?(String)
case frame
when "last"
frame=@totalFrames-1
when "middle"
frame=@totalFrames/2
when "start"
frame=0
else
raise _INTL(" AnimatedBitmapWrapper.toFrame() doesn't accept string: " + toFrame)
end
end
frame=@totalFrames if frame > @totalFrames
frame=0 if frame < 0
@currentIndex=frame
@actualBitmap.clear
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
#This method actually plays through the bitmap that was passed
def update
#Exits if the speed isn't 1 or greater.
return false if @speed < 1
case @speed
#Frames is a variable used to tell how many method calls this method ignores
#before it plays the next bitmap frame.
when 1
@frames=2
when 2
@frames=4
when 3
@frames=5
end
#Frame is a count for how many frames have elapsed. Or, rather, how many
#method calls have elapsed.
@frame+=1
#If the method call count is greater than how many calls we want to skip...
if @frame >=@frames
#Tragic #ADD [01/29/2018]
#If the currentIndex is less than one less than the start of the loop point
#OR is greater than/equal to one less than the end of the loop point...
if @currentIndex < @loop_points[0]-1 || @currentIndex >= @loop_points[1]-1
#Increase our loopCount. (The update method will reset the currentIndex to
#the loopPoints below if either of those are true.)
@loopCount+=1
end
#Update the frame position of our bitmap.
@currentIndex+=@direction
#Sets the frame position of our bitmap to be the starting loop point if we've
#passed, or are ate, the position of our ending loop point.
@currentIndex=@loop_points[0] if @currentIndex >=@loop_points[1]
#Sets the frame position of our bitmap to end loop point if we've passed,
#or are at, the position of the starting loop point.
@currentIndex=@loop_points[1]-1 if @currentIndex < @loop_points[0]
#Reset the method call counter.
@frame=0
end
#Clears the actual bitmap.
@actualBitmap.clear
#Updates the actual bitmap to the frame of the bitmap reel we want.
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
#A method that resets the bitmap to its starting position, and stops it from
#playing.
#Tragic #EDIT [05/02/2018]
#-Edited this method to have an optional paramater that allows us to reset the
#loopCount if we want to replay the animation.
#-Added a skip to frame optional parameter, additional handling for the toFrame parameter.
def deanimate(toFrame=0,resetLoops=false)
#If a string was passed to this method...
if toFrame.is_a?(String)
#Use our toFrame method to handle the frame selection.
toFrame(toFrame)
#If anything other than an int was passed...
elsif !toFrame.is_a?(Fixnum)
#Raise an error saying an invalid parameter was passed.
raise _INTL(" AnimatedBitmapWrapper.deanimate() does not accept non integers for toFrame!")
#If an int was passed...
else
#Set the frame to the int passed.
@frame=toFrame
#Tragic #EDIT [05/02/2018]
#Set the currentIndex to be the same as the current frame.
@currentIndex=toFrame
@actualBitmap.clear
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
#Tragic #ADD [01/28/2018]
#Resets our loop counter
@loopCount=0 if resetLoops
end
end
=begin
This class exposes two extra variables compared to AnimatedBitmapWrapper.
Middle? and Finished?
This class loses the "toFrame" method found inside the class AnimatedBitmapWrapper.
Which allows the wrapper to jump to a specific frame number.
It also does not have support for using loop points.
In general: This method is used for a straight shot/no loop animation that allows specific
things to be done when the bitmap has reached a specific position. When finished,
the bitmap will dispose itself.
"No loop" means it doesn't inherently loop on its own. Not that it can't be worked
around to make it.
=end
class AnimatedBitmapWrapperAnim
attr_reader :width
attr_reader :height
attr_reader :totalFrames
attr_reader :animationFrames
attr_reader :currentIndex
attr_reader :scale
#Called when creating a new instance of AnimatedBitmapWrapperAnim
def initialize(file,twoframe=false)
raise "filename is nil" if file==nil
@scale = 1 #Default 2, #Tragic #EDIT [01/26/2018]
@width = 0
@height = 0
@frame = 0
@frames = 2
@direction = +1
@twoframe = twoframe
@animationFinish = false
@totalFrames = 0
@currentIndex = 0
@finished=false
@middle=false
@speed = 1
# 0 - not moving at all
# 1 - normal speed
# 2 - medium speed
# 3 - slow speed
@bitmapFile=BitmapCache.load_bitmap(file)
# initializes full Pokemon bitmap
@bitmap=Bitmap.new(@bitmapFile.width,@bitmapFile.height)
@bitmap.blt(0,0,@bitmapFile,Rect.new(0,0,@bitmapFile.width,@bitmapFile.height))
@[email protected]*@scale
@[email protected]*@scale
@[email protected]/@bitmap.height
@animationFrames=@totalFrames*@frames
# calculates total number of frames
@loop_points=[0,@totalFrames]
# first value is start, second is end
@actualBitmap=Bitmap.new(@width,@height)
@actualBitmap.clear
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
#Methods that allow us to get specific information about our instanced class.
#The length (in frames) of a wrapped bitmap.
def length; @totalFrames; end
#A method that returns a boolean telling us if the bitmap has been disposed.
def disposed?; @actualBitmap.disposed?; end
#A method that forces the bitmap to be disposed.
def dispose; @actualBitmap.dispose; end
#A method that creates a copy of the wrapped bitmap that can be manipulated
#seperately from the original.
def copy; @actualBitmap.clone; end
#A method that returns the wrapped bitmap.
def bitmap; @actualBitmap; end
#A method that allows us to change the bitmap this instanced class is using.
def bitmap=(val); @actualBitmap=val; end
#I think this method allows us to do something for each frame in the file passed.
def each; end
#A method that returns a specific "frame" of the bitmap at the position passed.
def alterBitmap(index); return @strip[index]; end
#This method creates an array of bitmaps and places it into local var strip.
#Can probably be used to pull a bitmap of a specific frame if you want it, since
#this class does not have a toFrame method.
def prepareStrip
@strip=[]
for i in 0...@totalFrames
bitmap=Bitmap.new(@width,@height)
bitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmapFile,Rect.new((@width/@scale)*i,0,@width/@scale,@height/@scale))
@strip.push(bitmap)
end
end
#I'm not entirely sure what this method does, tbh.
def compileStrip
@bitmap.clear
for i in [email protected]
@bitmap.stretch_blt(Rect.new((@width/@scale)*i,0,@width/@scale,@height/@scale),@strip,Rect.new(0,0,@width,@height))
end
end
#This method allows us to reverse the current direction that the animated bitmap
#is playing in.
def reverse
if @direction > 0
@direction=-1
elsif @direction < 0
@direction=+1
end
end
#This method does not seem to have any use in this class.
#Reading the update method, there are no checks for this when it's playing.
def setLoop(start, finish)
@loop_points=[start,finish]
end
#This method allows us to change the speed that the wrapper will play the reel
#at.
def setSpeed(value)
@speed=value
end
#This method actually plays through the bitmap that was passed
def update
#Exits if the speed isn't 1 or greater.
return false if @speed < 1
case @speed
#Frames is a variable used to tell how many method calls this method ignores
#before it plays the next bitmap frame.
when 1
@frames=2
when 2
@frames=4
when 3
@frames=5
end
#Frame is a count for how many frames have elapsed. Or, rather, how many
#method calls have elapsed.
@frame+=1
#If the method call count is greater than how many calls we want to skip...
if @frame >=@frames
#If our current bitmap frame position is less than the total amount of frames
#in the bitmap...
if @currentIndex < @totalFrames
#Update the frame position of our bitmap.
@currentIndex+=@direction
end
#Reset the method call counter.
@frame=0
end
#Set the current frame position of our bitmap to the final frame if our current
#frame position is greater than the amount the bitmap has.
@currentIndex=@totalFrames if @currentIndex > @totalFrames
#Set our finished variable to true if we're at the end of the bitmap.
@finished=true if @currentIndex==@totalFrames
#Set our middle variable to true if we're at the halfway point of our bitmap.
@middle=true if @currentIndex==@totalFrames/2
#Clears the actual bitmap.
@actualBitmap.clear
#Updates the actual bitmap to the frame of the bitmap reel we want.
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
#A method that returns a boolean telling us if the bitmap has finished playing.
def finished?
return @finished
end
#A method that returns a boolean telling us if the bitmap is at/past the halfway
#point of its playing.
def middle?
return @middle
end
#A method that resets the bitmap to its starting position, and stops it from
#playing.
#Tragic #EDIT [04/19/2018]
#Added a parameter that allows this method to deanimate to a specific frame.
def deanimate(toFrame=0)
#Tragic #ADD [04/19/2018]
#Added code to handle deanimating to a specific frame.
#If toFrame was passed a number...
if toFrame.is_a?(Fixnum)
@frame=toFrame
#If toFrame was passed a string...
elsif toFrame.is_a?(String)
case toFrame
when "last"
@frame=@totalFrames-1
when "middle"
@frame=@totalFrames/2
when "start"
@frame=0
else
raise _INTL(" AnimatedBitmapWrapper.deanimate() doesn't accept string: " + toFrame)
end
end
@currentIndex=0
@actualBitmap.clear
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
end
end
class AnimatedBitmapWrapperLast < AnimatedBitmapWrapperAnim
def update
return false if @speed < 1
case @speed
# frame skip
when 1
@frames=2
when 2
@frames=4
when 3
@frames=5
end
@frame+=1
if @frame >=@frames
# processes animation speed
if @currentIndex < @totalFrames-1
@currentIndex+=@direction
end
@frame=0
end
@currentIndex=@totalFrames-1 if @currentIndex > @totalFrames-1
@finished=true if @currentIndex==@totalFrames-1
@actualBitmap.clear
@actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/@scale),0,@width/@scale,@height/@scale))
# updates the actual bitmap
end
end
#===============================================================================
# Aliases old PokemonBitmap generating functions and creates new ones,
# utilizing the new BitmapWrapper
#===============================================================================
alias pbLoadPokemonBitmap_old pbLoadPokemonBitmap
def pbLoadPokemonBitmap(pokemon, back=false,animate=false)
return pbLoadPokemonBitmapSpecies(pokemon,pokemon.species,back)
end
# Note: Returns an AnimatedBitmap, not a Bitmap
alias pbLoadPokemonBitmapSpecies_old pbLoadPokemonBitmapSpecies
def pbLoadPokemonBitmapSpecies(pokemon, species, back=false)
ret=nil
if pokemon.isEgg?
bitmapFileName=sprintf("Graphics/Battlers/Eggs/%segg",getConstantName(PBSpecies,species)) rescue nil
if !pbResolveBitmap(bitmapFileName)
bitmapFileName=sprintf("Graphics/Battlers/Eggs/%03degg",species)
if !pbResolveBitmap(bitmapFileName)
bitmapFileName=sprintf("Graphics/Battlers/Eggs/egg")
end
end
bitmapFileName=pbResolveBitmap(bitmapFileName)
else
bitmapFileName=pbCheckPokemonBitmapFiles([species,back,
(pokemon.isFemale?),
pokemon.isShiny?,
(pokemon.form rescue 0),
(pokemon.isShadow? rescue false)])
end
animatedBitmap=AnimatedBitmapWrapper.new(bitmapFileName) if bitmapFileName
ret=animatedBitmap if bitmapFileName
# Full compatibility with the alterBitmap methods is maintained
# but unless the alterBitmap method gets rewritten and sprite animations get
# hardcoded in the system, the bitmap alterations will not function properly
# as they will not account for the sprite animation itself
# alterBitmap methods for static sprites will work just fine
alterBitmap=(MultipleForms.getFunction(species,"alterBitmap") rescue nil) if !pokemon.isEgg? && animatedBitmap && animatedBitmap.totalFrames==1 # remove this totalFrames clause to allow for dynamic sprites too
if bitmapFileName && alterBitmap
animatedBitmap.prepareStrip
for i in 0...animatedBitmap.totalFrames
alterBitmap.call(pokemon,animatedBitmap.alterBitmap(i))
end
animatedBitmap.compileStrip
ret=animatedBitmap
end
return ret
end
def pbLoadFakePokemonBitmap(species,boy=false,shiny=false,form=0,back=false)
bitmapFileName=pbCheckPokemonBitmapFiles([species,back,
boy,
shiny,
form,
false])
animatedBitmap=AnimatedBitmapWrapper.new(bitmapFileName)
# echo("#{bitmapFileName}")
return animatedBitmap
end
#===============================================================================
# Misc. scripting tools
#===============================================================================
def pbBitmap(name)
return BitmapCache.load_bitmap(name)
end
class DynamicPokemonSprite
attr_accessor :selected
attr_accessor :shadow
attr_accessor :sprite
attr_accessor :src_rect
attr_accessor :showshadow
attr_accessor :status
attr_reader :loaded
def initialize(doublebattle,index,viewport=nil)
@viewport=viewport
@metrics=load_data("Data/metrics.dat")
@selected=0
@status=0
@loaded=false
@index=index
@doublebattle=doublebattle
@showshadow=true
@altitude=0
@yposition=0
@shadow=Sprite.new(@viewport)
@sprite=Sprite.new(@viewport)
@overlay=Sprite.new(@viewport)
@lock=false
end
def x; @sprite.x; end
def y; @sprite.y; end
def z; @sprite.z; end
def ox; @sprite.ox; end
def oy; @sprite.oy; end
def ox=(val);;end
def oy=(val);;end
def zoom_x; @sprite.zoom_x; end
def zoom_y; @sprite.zoom_y; end
def visible; @sprite.visible; end
def opacity; @sprite.opacity; end
def width; @bitmap.width; end
def height; @bitmap.height; end
def tone; @sprite.tone; end
def bitmap; @bitmap.bitmap; end
def actualBitmap; @bitmap; end
def disposed?; @sprite.disposed?; end
def color; @sprite.color; end
def src_rect; @sprite.src_rect; end
def blend_type; @sprite.blend_type; end
def angle; @sprite.angle; end
def mirror; @sprite.mirror; end
def lock
@lock=true
end
def unlock
@lock=true
end
def bitmap=(val)
@bitmap.bitmap=val
end
def x=(val)
@sprite.x=val
@shadow.x=val
end
def ox=(val)
@sprite.ox=val
self.formatShadow
end
def oy=(val)
@sprite.oy=val
self.formatShadow
end
def y=(val)
@sprite.y=val
@shadow.y=val
end
def z=(val)
@shadow.z=10
@sprite.z=val
end
def zoom_x=(val)
@sprite.zoom_x=val
self.formatShadow
end
def zoom_y=(val)
@sprite.zoom_y=val
self.formatShadow
end
def visible=(val)
@sprite.visible=val
self.formatShadow
end
def opacity=(val)
@sprite.opacity=val
self.formatShadow
end
def tone=(val)
@sprite.tone=val
self.formatShadow
end
def color=(val)
@sprite.color=val
self.formatShadow
end
def blend_type=(val)
@sprite.blend_type=val
self.formatShadow
end
def angle=(val)
@sprite.angle=(val)
self.formatShadow
end
def mirror=(val)
@sprite.mirror=(val)
self.formatShadow
end
def dispose
@sprite.dispose
@shadow.dispose
end
def setPokemonBitmap(pokemon,back=false)
@altitude=@metrics[2][pokemon.species]
@yposition=back ? @metrics[0][pokemon.species] : @metrics[1][pokemon.species]
@xpos=back ? @metrics[4][pokemon.species] : @metrics[3][pokemon.species]
if back
@altitude/=2
@yposition/=2
end
@bitmap=pbLoadPokemonBitmap(pokemon,back)
@[email protected]
@[email protected]
@[email protected]/2+@xpos
@[email protected]
@sprite.oy+=@altitude
@sprite.oy-=@yposition
@loaded=true
self.formatShadow
@shadow.skew(70)
end
def formatShadow
@[email protected]_x*0.80
@[email protected]_y*0.20-(0.0020*@altitude)
@[email protected]
@[email protected]@altitude
@[email protected]*0.3
#@[email protected]
@shadow.tone=Tone.new(-255,-255,-255,255)
@[email protected]
@[email protected]
@shadow.visible=false if !@showshadow
end
=begin
def formatShadow
@[email protected]_x*1.1-(0.011*@altitude)
@[email protected]_y*0.32-(0.0032*@altitude)
@[email protected]
@[email protected]@altitude
@[email protected]*0.3
@[email protected]
@shadow.tone=Tone.new(-255,-255,-255,255)
@[email protected]
@[email protected]
@shadow.visible=false if !@showshadow
end
=end
def update
return if @lock
if @bitmap
@bitmap.update
@[email protected]
@[email protected]
@shadow.skew(70)
end
case @status
when 0
@sprite.color=Color.new(0,0,0,0)
when 1 #PSN
@sprite.color=Color.new(153,102,204,50)
when 2 #PAR
@sprite.color=Color.new(255,255,153,50)
when 3 #FRZ
@sprite.color=Color.new(153,204,204,50)
when 4 #BRN
@sprite.color=Color.new(204,51,51,50)
end
self.formatShadow
end
end
class DynamicTrainerSprite < DynamicPokemonSprite
def totalFrames; @bitmap.animationFrames; end
def toLastFrame; @bitmap.toFrame("last"); end
def selected; end
def setTrainerBitmap(file)
@bitmap=AnimatedBitmapWrapper.new(file)
@[email protected]
@[email protected]
@[email protected]/2
if @doublebattle
if @index==-2
@sprite.ox-=50
elsif @index==-1
@sprite.ox+=50
end
end
@[email protected]
self.formatShadow
@shadow.skew(70)
end
def update
return if @lock
if @bitmap
@bitmap.update
@[email protected]
@[email protected]
@shadow.skew(70)
end
case @status
when 0
@sprite.color=Color.new(0,0,0,0)
when 1 #PSN
@sprite.color=Color.new(153,102,204,50)
when 2 #PAR
@sprite.color=Color.new(255,255,153,50)
when 3 #FRZ
@sprite.color=Color.new(153,204,204,50)
when 4 #BRN
@sprite.color=Color.new(204,51,51,50)
end
self.formatShadow
end
end
class TrainerSpriteBW
attr_accessor :selected
attr_accessor :shadow
attr_accessor :sprite
attr_accessor :src_rect
attr_accessor :showshadow
attr_accessor :status
attr_reader :loaded
def initialize(x,y,viewport=nil)
@viewport=viewport
@metrics=load_data("Data/metrics.dat")
@selected=0
@status=0
@loaded=false
@showshadow=false
@altitude=0
@yposition=0
@shadow=Sprite.new(@viewport)
@sprite=Sprite.new(@viewport)
@sprite.x=x
@sprite.y=y
@overlay=Sprite.new(@viewport)
@lock=false
end
def x; @sprite.x; end
def y; @sprite.y; end
def z; @sprite.z; end
def ox; @sprite.ox; end
def oy; @sprite.oy; end
def ox=(val);;end
def oy=(val);;end
def zoom_x; @sprite.zoom_x; end
def zoom_y; @sprite.zoom_y; end
def visible; @sprite.visible; end
def opacity; @sprite.opacity; end
def width; @bitmap.width; end
def height; @bitmap.height; end
def tone; @sprite.tone; end
def bitmap; @bitmap.bitmap; end
def actualBitmap; @bitmap; end
def disposed?; @sprite.disposed?; end
def color; @sprite.color; end
def src_rect; @sprite.src_rect; end
def blend_type; @sprite.blend_type; end
def angle; @sprite.angle; end
def mirror; @sprite.mirror; end
def lock
@lock=true
end
def unlock
@lock=false
end
def bitmap=(val)
@bitmap.bitmap=val
end
def finished?
return @bitmap.finished?
end
def x=(val)
@sprite.x=val
@shadow.x=val
end
def ox=(val)
@sprite.ox=val
self.formatShadow
end
def oy=(val)
@sprite.oy=val
self.formatShadow
end
def y=(val)
@sprite.y=val
@shadow.y=val
end
def z=(val)
@shadow.z=10
@sprite.z=val
end
def zoom_x=(val)
@sprite.zoom_x=val
self.formatShadow
end
def zoom_y=(val)
@sprite.zoom_y=val
self.formatShadow
end
def visible=(val)
@sprite.visible=val
self.formatShadow
end
def opacity=(val)
@sprite.opacity=val
self.formatShadow
end
def tone=(val)
@sprite.tone=val
self.formatShadow
end
def color=(val)
@sprite.color=val
self.formatShadow
end
def blend_type=(val)
@sprite.blend_type=val
self.formatShadow
end
def angle=(val)
@sprite.angle=(val)
self.formatShadow
end
def mirror=(val)
@sprite.mirror=(val)
self.formatShadow
end
def dispose
@sprite.dispose
@shadow.dispose
end
def totalFrames; @bitmap.animationFrames; end
def toLastFrame; @bitmap.toFrame("last"); end
def selected; end
def setBitmap(file)
@bitmap=AnimatedBitmapWrapperLast.new(file)
@[email protected]
@[email protected]
self.formatShadow
end
def formatShadow
@[email protected]_x*1.1-(0.011*@altitude)
@[email protected]_y*0.32-(0.0032*@altitude)
@[email protected]
@[email protected]@altitude
@[email protected]*0.3
@[email protected]
@shadow.tone=Tone.new(-255,-255,-255,255)
@[email protected]
@[email protected]
@shadow.visible=false if !@showshadow
end
def update
return if @lock
if @bitmap
@bitmap.update
@[email protected]
@[email protected]
end
self.formatShadow
end
end
class PokemonSpriteBW
attr_accessor :selected
attr_accessor :shadow
attr_accessor :sprite
attr_accessor :src_rect
attr_accessor :showshadow
attr_accessor :status
attr_reader :loaded
def initialize(viewport=nil)
@viewport=viewport
@metrics=load_data("Data/metrics.dat")
@selected=0
@status=0
@loaded=false
@showshadow=true
@altitude=0
@yposition=0
@sprite=Sprite.new(@viewport)
@overlay=Sprite.new(@viewport)
@lock=false
end
def x; @sprite.x; end
def y; @sprite.y; end
def z; @sprite.z; end
def ox; @sprite.ox; end
def oy; @sprite.oy; end
def ox=(val);;end
def oy=(val);;end
def zoom_x; @sprite.zoom_x; end
def zoom_y; @sprite.zoom_y; end
def visible; @sprite.visible; end
def opacity; @sprite.opacity; end
def width; @bitmap.width; end
def height; @bitmap.height; end
def tone; @sprite.tone; end
def bitmap; @bitmap.bitmap; end
def actualBitmap; @bitmap; end
def disposed?; @sprite.disposed?; end
def color; @sprite.color; end
def src_rect; @sprite.src_rect; end
def blend_type; @sprite.blend_type; end
def angle; @sprite.angle; end
def mirror; @sprite.mirror; end
def lock
@lock=true
end
def unlock
@lock=false
end
def bitmap=(val)
@bitmap.bitmap=val
end
def x=(val)
@sprite.x=val
end
def ox=(val)
@sprite.ox=val
end
def oy=(val)
@sprite.oy=val
end
def y=(val)
@sprite.y=val
end
def z=(val)
@sprite.z=val
end
def zoom_x=(val)
@sprite.zoom_x=val
end
def zoom_y=(val)
@sprite.zoom_y=val
end
def visible=(val)
@sprite.visible=val
end
def opacity=(val)
@sprite.opacity=val
end
def tone=(val)
@sprite.tone=val
end
def color=(val)
@sprite.color=val
end
def blend_type=(val)
@sprite.blend_type=val
end
def angle=(val)
@sprite.angle=(val)
end
def mirror=(val)
@sprite.mirror=(val)
end
def dispose
@sprite.dispose
end
def setPokemonBitmap(pokemon,back=false)
@bitmap=pbLoadPokemonBitmap(pokemon,back)
@[email protected]
@[email protected]/2
@[email protected]/2
@loaded=true
end
def update
return if @lock
if @bitmap
@bitmap.update
@[email protected]
end
end
end
class GifAnim
attr_accessor :selected
attr_accessor :shadow
attr_accessor :sprite
attr_accessor :src_rect
attr_accessor :showshadow
attr_accessor :status
attr_reader :loaded
def initialize(x,y,viewport=nil,repeat=false)
@viewport=viewport
@metrics=load_data("Data/metrics.dat")
@selected=0
@status=0
@loaded=false
@repeat=repeat
@showshadow=false
@altitude=0
@yposition=0
@sprite=Sprite.new(@viewport)
@sprite.x=x
@sprite.y=y
@overlay=Sprite.new(@viewport)
@lock=false
end
def x; @sprite.x; end
def y; @sprite.y; end
def z; @sprite.z; end
def ox; @sprite.ox; end
def oy; @sprite.oy; end
def ox=(val);;end
def oy=(val);;end
def zoom_x; @sprite.zoom_x; end
def zoom_y; @sprite.zoom_y; end
def visible; @sprite.visible; end
def opacity; @sprite.opacity; end
def width; @bitmap.width; end
def height; @bitmap.height; end
def tone; @sprite.tone; end
def bitmap; @bitmap.bitmap; end
def actualBitmap; @bitmap; end
def disposed?; @sprite.disposed?; end
def color; @sprite.color; end
def src_rect; @sprite.src_rect; end
def blend_type; @sprite.blend_type; end
def angle; @sprite.angle; end
def mirror; @sprite.mirror; end
def lock
@lock=true
end
def unlock
@lock=false
end
def bitmap=(val)
@bitmap.bitmap=val
end
def finished?
return @bitmap.finished?
end
def middle?
return @bitmap.middle?
end
def x=(val)
@sprite.x=val
end
def ox=(val)
@sprite.ox=val
end
def oy=(val)
@sprite.oy=val
end
def y=(val)
@sprite.y=val
end
def zoom_x=(val)
@sprite.zoom_x=val
end
def zoom_y=(val)
@sprite.zoom_y=val
end
def visible=(val)
@sprite.visible=val
end
def opacity=(val)
@sprite.opacity=val
end
def tone=(val)
@sprite.tone=val
end
def color=(val)
@sprite.color=val
end
def blend_type=(val)
@sprite.blend_type=val
end
def angle=(val)
@sprite.angle=(val)
end
def mirror=(val)
@sprite.mirror=(val)
end
def dispose
@sprite.dispose
end
def z=(val)
@sprite.z=val
end
def totalFrames; @bitmap.animationFrames; end
def toLastFrame; @bitmap.toFrame("last"); end
def selected; end
def setBitmap(file)
if !@repeat
@bitmap=AnimatedBitmapWrapperAnim.new(file)
@[email protected]/2
@[email protected]/2
else
@bitmap=AnimatedBitmapWrapper.new(file)
@bitmap.setSpeed(2)
@[email protected]/2
end
@[email protected]
end
def update
return if @lock
if @bitmap
@bitmap.update
@[email protected]
end
end
end
#=end