mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -19,8 +19,8 @@ class Sprite_Picture
|
||||
# If file name is not empty
|
||||
if @picture_name != ""
|
||||
# Get picture graphic
|
||||
@sprite=IconSprite.new(0,0,@viewport) if !@sprite
|
||||
@sprite.setBitmap("Graphics/Pictures/"+@picture_name)
|
||||
@sprite = IconSprite.new(0, 0, @viewport) if !@sprite
|
||||
@sprite.setBitmap("Graphics/Pictures/" + @picture_name)
|
||||
end
|
||||
end
|
||||
# If file name is empty
|
||||
@@ -28,7 +28,7 @@ class Sprite_Picture
|
||||
# Set sprite to invisible
|
||||
if @sprite
|
||||
@sprite.dispose if @sprite
|
||||
@sprite=nil
|
||||
@sprite = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class Sprite_Timer
|
||||
def initialize(viewport = nil)
|
||||
@viewport=viewport
|
||||
@timer=nil
|
||||
@total_sec=nil
|
||||
@disposed=false
|
||||
@viewport = viewport
|
||||
@timer = nil
|
||||
@total_sec = nil
|
||||
@disposed = false
|
||||
end
|
||||
|
||||
def dispose
|
||||
@timer.dispose if @timer
|
||||
@timer=nil
|
||||
@disposed=true
|
||||
@timer = nil
|
||||
@disposed = true
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@@ -21,14 +21,14 @@ class Sprite_Timer
|
||||
if $game_system.timer_working
|
||||
@timer.visible = true if @timer
|
||||
if !@timer
|
||||
@timer=Window_AdvancedTextPokemon.newWithSize("",Graphics.width-120,0,120,64)
|
||||
@timer.width=@timer.borderX+96
|
||||
@timer.x=Graphics.width-@timer.width
|
||||
@timer.viewport=@viewport
|
||||
@timer.z=99998
|
||||
@timer = Window_AdvancedTextPokemon.newWithSize("", Graphics.width - 120, 0, 120, 64)
|
||||
@timer.width = @timer.borderX + 96
|
||||
@timer.x = Graphics.width - @timer.width
|
||||
@timer.viewport = @viewport
|
||||
@timer.z = 99998
|
||||
end
|
||||
curtime=$game_system.timer / Graphics.frame_rate
|
||||
curtime=0 if curtime<0
|
||||
curtime = $game_system.timer / Graphics.frame_rate
|
||||
curtime = 0 if curtime < 0
|
||||
if curtime != @total_sec
|
||||
# Calculate total number of seconds
|
||||
@total_sec = curtime
|
||||
@@ -39,7 +39,7 @@ class Sprite_Timer
|
||||
end
|
||||
@timer.update
|
||||
else
|
||||
@timer.visible=false if @timer
|
||||
@timer.visible = false if @timer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,13 +2,13 @@ class Sprite_Reflection
|
||||
attr_reader :visible
|
||||
attr_accessor :event
|
||||
|
||||
def initialize(sprite,event,viewport = nil)
|
||||
def initialize(sprite, event, viewport = nil)
|
||||
@rsprite = sprite
|
||||
@sprite = nil
|
||||
@event = event
|
||||
@height = 0
|
||||
@fixedheight = false
|
||||
if @event && @event!=$game_player
|
||||
if @event && @event != $game_player
|
||||
if @event.name[/reflection\((\d+)\)/i]
|
||||
@height = $~[1].to_i || 0
|
||||
@fixedheight = true
|
||||
@@ -50,35 +50,35 @@ class Sprite_Reflection
|
||||
# Just-in-time creation of sprite
|
||||
@sprite = Sprite.new(@viewport) if !@sprite
|
||||
if @sprite
|
||||
x = @rsprite.x-@rsprite.ox
|
||||
y = @rsprite.y-@rsprite.oy
|
||||
x = @rsprite.x - @rsprite.ox
|
||||
y = @rsprite.y - @rsprite.oy
|
||||
y -= 32 if @rsprite.character.character_name[/offset/i]
|
||||
@height = $PokemonGlobal.bridge if !@fixedheight
|
||||
y += @height*16
|
||||
y += @height * 16
|
||||
width = @rsprite.src_rect.width
|
||||
height = @rsprite.src_rect.height
|
||||
@sprite.x = x+width/2
|
||||
@sprite.y = y+height+height/2
|
||||
@sprite.ox = width/2
|
||||
@sprite.oy = height/2-2 # Hard-coded 2 pixel shift up
|
||||
@sprite.oy -= @rsprite.character.bob_height*2
|
||||
@sprite.x = x + width / 2
|
||||
@sprite.y = y + height + height / 2
|
||||
@sprite.ox = width / 2
|
||||
@sprite.oy = height / 2 - 2 # Hard-coded 2 pixel shift up
|
||||
@sprite.oy -= @rsprite.character.bob_height * 2
|
||||
@sprite.z = -50 # Still water is -100, map is 0 and above
|
||||
@sprite.z += 1 if @event == $game_player
|
||||
@sprite.zoom_x = @rsprite.zoom_x
|
||||
@sprite.zoom_y = @rsprite.zoom_y
|
||||
frame = (Graphics.frame_count%40)/10
|
||||
frame = (Graphics.frame_count % 40) / 10
|
||||
@sprite.zoom_x *= [1.0, 0.95, 1.0, 1.05][frame]
|
||||
@sprite.angle = 180.0
|
||||
@sprite.mirror = true
|
||||
@sprite.bitmap = @rsprite.bitmap
|
||||
@sprite.tone = @rsprite.tone
|
||||
if @height>0
|
||||
@sprite.color = Color.new(48,96,160,255) # Dark still water
|
||||
if @height > 0
|
||||
@sprite.color = Color.new(48, 96, 160, 255) # Dark still water
|
||||
@sprite.opacity = @rsprite.opacity
|
||||
@sprite.visible = !Settings::TIME_SHADING # Can't time-tone a colored sprite
|
||||
else
|
||||
@sprite.color = Color.new(224,224,224,96)
|
||||
@sprite.opacity = @rsprite.opacity*3/4
|
||||
@sprite.color = Color.new(224, 224, 224, 96)
|
||||
@sprite.opacity = @rsprite.opacity * 3 / 4
|
||||
@sprite.visible = true
|
||||
end
|
||||
@sprite.src_rect = @rsprite.src_rect
|
||||
|
||||
@@ -2,7 +2,7 @@ class Sprite_SurfBase
|
||||
attr_reader :visible
|
||||
attr_accessor :event
|
||||
|
||||
def initialize(sprite,event,viewport = nil)
|
||||
def initialize(sprite, event, viewport = nil)
|
||||
@rsprite = sprite
|
||||
@sprite = nil
|
||||
@event = event
|
||||
@@ -12,10 +12,10 @@ class Sprite_SurfBase
|
||||
@divebitmap = AnimatedBitmap.new("Graphics/Characters/base_dive")
|
||||
RPG::Cache.retain("Graphics/Characters/base_surf")
|
||||
RPG::Cache.retain("Graphics/Characters/base_dive")
|
||||
@cws = @surfbitmap.width/4
|
||||
@chs = @surfbitmap.height/4
|
||||
@cwd = @divebitmap.width/4
|
||||
@chd = @divebitmap.height/4
|
||||
@cws = @surfbitmap.width / 4
|
||||
@chs = @surfbitmap.height / 4
|
||||
@cwd = @divebitmap.width / 4
|
||||
@chd = @divebitmap.height / 4
|
||||
update
|
||||
end
|
||||
|
||||
@@ -59,9 +59,9 @@ class Sprite_SurfBase
|
||||
cw = @cwd
|
||||
ch = @chd
|
||||
end
|
||||
sx = @event.pattern_surf*cw
|
||||
sy = ((@event.direction-2)/2)*ch
|
||||
@sprite.src_rect.set(sx,sy,cw,ch)
|
||||
sx = @event.pattern_surf * cw
|
||||
sy = ((@event.direction - 2) / 2) * ch
|
||||
@sprite.src_rect.set(sx, sy, cw, ch)
|
||||
if $game_temp.surf_base_coords
|
||||
@sprite.x = ($game_temp.surf_base_coords[0] * Game_Map::REAL_RES_X - @event.map.display_x + 3) / 4 + (Game_Map::TILE_WIDTH / 2)
|
||||
@sprite.y = ($game_temp.surf_base_coords[1] * Game_Map::REAL_RES_Y - @event.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT / 2) + 16
|
||||
@@ -69,10 +69,10 @@ class Sprite_SurfBase
|
||||
@sprite.x = @rsprite.x
|
||||
@sprite.y = @rsprite.y
|
||||
end
|
||||
@sprite.ox = cw/2
|
||||
@sprite.oy = ch-16 # Assume base needs offsetting
|
||||
@sprite.ox = cw / 2
|
||||
@sprite.oy = ch - 16 # Assume base needs offsetting
|
||||
@sprite.oy -= @event.bob_height
|
||||
@sprite.z = @event.screen_z(ch)-1
|
||||
@sprite.z = @event.screen_z(ch) - 1
|
||||
@sprite.zoom_x = @rsprite.zoom_x
|
||||
@sprite.zoom_y = @rsprite.zoom_y
|
||||
@sprite.tone = @rsprite.tone
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
# Unused
|
||||
class ClippableSprite < Sprite_Character
|
||||
def initialize(viewport,event,tilemap)
|
||||
def initialize(viewport, event, tilemap)
|
||||
@tilemap = tilemap
|
||||
@_src_rect = Rect.new(0,0,0,0)
|
||||
super(viewport,event)
|
||||
@_src_rect = Rect.new(0, 0, 0, 0)
|
||||
super(viewport, event)
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
@_src_rect = self.src_rect
|
||||
tmright = @tilemap.map_data.xsize*Game_Map::TILE_WIDTH-@tilemap.ox
|
||||
tmright = @tilemap.map_data.xsize * Game_Map::TILE_WIDTH - @tilemap.ox
|
||||
echoln "x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}"
|
||||
if @tilemap.ox-self.ox<-self.x
|
||||
if @tilemap.ox - self.ox < -self.x
|
||||
# clipped on left
|
||||
diff = -self.x-@tilemap.ox+self.ox
|
||||
self.src_rect = Rect.new(@_src_rect.x+diff,@_src_rect.y,
|
||||
@_src_rect.width-diff,@_src_rect.height)
|
||||
echoln "clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}"
|
||||
elsif tmright-self.ox<self.x
|
||||
diff = -self.x - @tilemap.ox + self.ox
|
||||
self.src_rect = Rect.new(@_src_rect.x + diff, @_src_rect.y,
|
||||
@_src_rect.width - diff, @_src_rect.height)
|
||||
echoln "clipped out left: #{diff} #{@tilemap.ox - self.ox} #{self.x}"
|
||||
elsif tmright - self.ox < self.x
|
||||
# clipped on right
|
||||
diff = self.x-tmright+self.ox
|
||||
self.src_rect = Rect.new(@_src_rect.x,@_src_rect.y,
|
||||
@_src_rect.width-diff,@_src_rect.height)
|
||||
echoln "clipped out right: #{diff} #{tmright+self.ox} #{self.x}"
|
||||
diff = self.x - tmright + self.ox
|
||||
self.src_rect = Rect.new(@_src_rect.x, @_src_rect.y,
|
||||
@_src_rect.width - diff, @_src_rect.height)
|
||||
echoln "clipped out right: #{diff} #{tmright + self.ox} #{self.x}"
|
||||
else
|
||||
echoln "-not- clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}"
|
||||
echoln "-not- clipped out left: #{diff} #{@tilemap.ox - self.ox} #{self.x}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -55,11 +55,11 @@ class Spriteset_Map
|
||||
@fog.z = 3000
|
||||
@character_sprites = []
|
||||
for i in @map.events.keys.sort
|
||||
sprite = Sprite_Character.new(@@viewport1,@map.events[i])
|
||||
sprite = Sprite_Character.new(@@viewport1, @map.events[i])
|
||||
@character_sprites.push(sprite)
|
||||
end
|
||||
@weather = RPG::Weather.new(@@viewport1)
|
||||
pbOnSpritesetCreate(self,@@viewport1)
|
||||
pbOnSpritesetCreate(self, @@viewport1)
|
||||
update
|
||||
end
|
||||
|
||||
@@ -90,32 +90,32 @@ class Spriteset_Map
|
||||
end
|
||||
|
||||
def update
|
||||
if @panorama_name!=@map.panorama_name || @panorama_hue!=@map.panorama_hue
|
||||
if @panorama_name != @map.panorama_name || @panorama_hue != @map.panorama_hue
|
||||
@panorama_name = @map.panorama_name
|
||||
@panorama_hue = @map.panorama_hue
|
||||
@panorama.set_panorama(nil) if !@panorama.bitmap.nil?
|
||||
@panorama.set_panorama(@panorama_name, @panorama_hue) if !nil_or_empty?(@panorama_name)
|
||||
Graphics.frame_reset
|
||||
end
|
||||
if @fog_name!=@map.fog_name || @fog_hue!=@map.fog_hue
|
||||
if @fog_name != @map.fog_name || @fog_hue != @map.fog_hue
|
||||
@fog_name = @map.fog_name
|
||||
@fog_hue = @map.fog_hue
|
||||
@fog.set_fog(nil) if !@fog.bitmap.nil?
|
||||
@fog.set_fog(@fog_name, @fog_hue) if !nil_or_empty?(@fog_name)
|
||||
Graphics.frame_reset
|
||||
end
|
||||
tmox = (@map.display_x/Game_Map::X_SUBPIXELS).round
|
||||
tmoy = (@map.display_y/Game_Map::Y_SUBPIXELS).round
|
||||
@@viewport1.rect.set(0,0,Graphics.width,Graphics.height)
|
||||
tmox = (@map.display_x / Game_Map::X_SUBPIXELS).round
|
||||
tmoy = (@map.display_y / Game_Map::Y_SUBPIXELS).round
|
||||
@@viewport1.rect.set(0, 0, Graphics.width, Graphics.height)
|
||||
@@viewport1.ox = 0
|
||||
@@viewport1.oy = 0
|
||||
@@viewport1.ox += $game_screen.shake
|
||||
@panorama.ox = tmox/2
|
||||
@panorama.oy = tmoy/2
|
||||
@fog.ox = tmox+@map.fog_ox
|
||||
@fog.oy = tmoy+@map.fog_oy
|
||||
@fog.zoom_x = @map.fog_zoom/100.0
|
||||
@fog.zoom_y = @map.fog_zoom/100.0
|
||||
@panorama.ox = tmox / 2
|
||||
@panorama.oy = tmoy / 2
|
||||
@fog.ox = tmox + @map.fog_ox
|
||||
@fog.oy = tmoy + @map.fog_oy
|
||||
@fog.zoom_x = @map.fog_zoom / 100.0
|
||||
@fog.zoom_y = @map.fog_zoom / 100.0
|
||||
@fog.opacity = @map.fog_opacity
|
||||
@fog.blend_type = @map.fog_blend_type
|
||||
@fog.tone = @map.fog_tone
|
||||
@@ -124,7 +124,7 @@ class Spriteset_Map
|
||||
for sprite in @character_sprites
|
||||
sprite.update
|
||||
end
|
||||
if self.map!=$game_map
|
||||
if self.map != $game_map
|
||||
@weather.fade_in(:None, 0, 20)
|
||||
else
|
||||
@weather.fade_in($game_screen.weather_type, $game_screen.weather_max, $game_screen.weather_duration)
|
||||
|
||||
@@ -5,7 +5,7 @@ automatically when its animation is finished.
|
||||
Used for grass rustling and so forth.
|
||||
=end
|
||||
class AnimationSprite < RPG::Sprite
|
||||
def initialize(animID,map,tileX,tileY,viewport = nil,tinting = false,height = 3)
|
||||
def initialize(animID, map, tileX, tileY, viewport = nil, tinting = false, height = 3)
|
||||
super(viewport)
|
||||
@tileX = tileX
|
||||
@tileY = tileY
|
||||
@@ -14,7 +14,7 @@ class AnimationSprite < RPG::Sprite
|
||||
@map = map
|
||||
setCoords
|
||||
pbDayNightTint(self) if tinting
|
||||
self.animation($data_animations[animID],true,height)
|
||||
self.animation($data_animations[animID], true, height)
|
||||
end
|
||||
|
||||
def setCoords
|
||||
@@ -46,20 +46,20 @@ class Spriteset_Map
|
||||
alias _animationSprite_dispose dispose
|
||||
|
||||
def initialize(map = nil)
|
||||
@usersprites=[]
|
||||
@usersprites = []
|
||||
_animationSprite_initialize(map)
|
||||
end
|
||||
|
||||
def addUserAnimation(animID,x,y,tinting = false,height = 3)
|
||||
sprite=AnimationSprite.new(animID,self.map,x,y,@@viewport1,tinting,height)
|
||||
def addUserAnimation(animID, x, y, tinting = false, height = 3)
|
||||
sprite = AnimationSprite.new(animID, self.map, x, y, @@viewport1, tinting, height)
|
||||
addUserSprite(sprite)
|
||||
return sprite
|
||||
end
|
||||
|
||||
def addUserSprite(sprite)
|
||||
for i in 0...@usersprites.length
|
||||
if @usersprites[i]==nil || @usersprites[i].disposed?
|
||||
@usersprites[i]=sprite
|
||||
if @usersprites[i] == nil || @usersprites[i].disposed?
|
||||
@usersprites[i] = sprite
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -75,7 +75,7 @@ class Spriteset_Map
|
||||
end
|
||||
|
||||
def update
|
||||
@@viewport3.tone.set(0,0,0,0)
|
||||
@@viewport3.tone.set(0, 0, 0, 0)
|
||||
_animationSprite_update
|
||||
for i in 0...@usersprites.length
|
||||
@usersprites[i].update if !@usersprites[i].disposed?
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
class Sprite_Shadow < RPG::Sprite
|
||||
attr_accessor :character
|
||||
|
||||
def initialize(viewport, character = nil,params = [])
|
||||
def initialize(viewport, character = nil, params = [])
|
||||
super(viewport)
|
||||
@source = params[0]
|
||||
@anglemin = (params.size>1) ? params[1] : 0
|
||||
@anglemax = (params.size>2) ? params[2] : 0
|
||||
@self_opacity = (params.size>4) ? params[4] : 100
|
||||
@distancemax = (params.size>3) ? params[3] : 350
|
||||
@anglemin = (params.size > 1) ? params[1] : 0
|
||||
@anglemax = (params.size > 2) ? params[2] : 0
|
||||
@self_opacity = (params.size > 4) ? params[4] : 100
|
||||
@distancemax = (params.size > 3) ? params[3] : 350
|
||||
@character = character
|
||||
update
|
||||
end
|
||||
@@ -47,7 +47,7 @@ class Sprite_Shadow < RPG::Sprite
|
||||
else
|
||||
@chbitmap.dispose if @chbitmap
|
||||
@chbitmap = AnimatedBitmap.new(
|
||||
'Graphics/Characters/'+@character.character_name,@character.character_hue)
|
||||
'Graphics/Characters/' + @character.character_name, @character.character_hue)
|
||||
@cw = @chbitmap.width / 4
|
||||
@ch = @chbitmap.height / 4
|
||||
self.ox = @cw / 2
|
||||
@@ -75,8 +75,8 @@ class Sprite_Shadow < RPG::Sprite
|
||||
self.src_rect.set(sx, sy, @cw, @ch)
|
||||
end
|
||||
self.x = ScreenPosHelper.pbScreenX(@character)
|
||||
self.y = ScreenPosHelper.pbScreenY(@character)-5
|
||||
self.z = ScreenPosHelper.pbScreenZ(@character,@ch)-1
|
||||
self.y = ScreenPosHelper.pbScreenY(@character) - 5
|
||||
self.z = ScreenPosHelper.pbScreenZ(@character, @ch) - 1
|
||||
self.zoom_x = ScreenPosHelper.pbScreenZoomX(@character)
|
||||
self.zoom_y = ScreenPosHelper.pbScreenZoomY(@character)
|
||||
self.blend_type = @character.blend_type
|
||||
@@ -89,10 +89,10 @@ class Sprite_Shadow < RPG::Sprite
|
||||
@deltax = ScreenPosHelper.pbScreenX(@source) - self.x
|
||||
@deltay = ScreenPosHelper.pbScreenY(@source) - self.y
|
||||
self.color = Color.new(0, 0, 0)
|
||||
@distance = ((@deltax ** 2) + (@deltay ** 2))
|
||||
@distance = ((@deltax**2) + (@deltay**2))
|
||||
self.opacity = @self_opacity * 13000 / ((@distance * 370 / @distancemax) + 6000)
|
||||
self.angle = 57.3 * Math.atan2(@deltax, @deltay)
|
||||
@angle_trigo = self.angle+90
|
||||
@angle_trigo = self.angle + 90
|
||||
@angle_trigo += 360 if @angle_trigo < 0
|
||||
if @anglemin != 0 || @anglemax != 0
|
||||
if (@angle_trigo < @anglemin || @angle_trigo > @anglemax) && @anglemin < @anglemax
|
||||
@@ -132,9 +132,9 @@ class Sprite_Character < RPG::Sprite
|
||||
shadow_initialize(viewport, @character)
|
||||
end
|
||||
|
||||
def setShadows(map,shadows)
|
||||
def setShadows(map, shadows)
|
||||
if character.is_a?(Game_Event) && shadows.length > 0
|
||||
params = XPML_read(map,"Shadow",@character,4)
|
||||
params = XPML_read(map, "Shadow", @character, 4)
|
||||
if params != nil
|
||||
for i in 0...shadows.size
|
||||
@ombrelist.push(Sprite_Shadow.new(viewport, @character, shadows[i]))
|
||||
@@ -158,7 +158,7 @@ class Sprite_Character < RPG::Sprite
|
||||
|
||||
def update
|
||||
shadow_update
|
||||
if @ombrelist.length>0
|
||||
if @ombrelist.length > 0
|
||||
for i in 0...@ombrelist.size
|
||||
@ombrelist[i].update
|
||||
end
|
||||
@@ -193,7 +193,7 @@ class Spriteset_Map
|
||||
warn = true if (ev.list != nil && ev.list.length > 0 &&
|
||||
ev.list[0].code == 108 &&
|
||||
(ev.list[0].parameters == ["s"] || ev.list[0].parameters == ["o"]))
|
||||
params = XPML_read(map,"Shadow Source", ev, 4)
|
||||
params = XPML_read(map, "Shadow Source", ev, 4)
|
||||
@shadows.push([ev] + params) if params != nil
|
||||
end
|
||||
if warn == true
|
||||
@@ -228,14 +228,14 @@ end
|
||||
# p XPML_read("third", event_id) -> [3]
|
||||
# p XPML_read("forth", event_id) -> nil
|
||||
#===================================================
|
||||
def XPML_read(map,markup,event,max_param_number = 0)
|
||||
def XPML_read(map, markup, event, max_param_number = 0)
|
||||
parameter_list = nil
|
||||
return nil if !event || event.list == nil
|
||||
for i in 0...event.list.size
|
||||
if event.list[i].code == 108 &&
|
||||
event.list[i].parameters[0].downcase == "begin " + markup.downcase
|
||||
parameter_list = [] if parameter_list == nil
|
||||
for j in i+1...event.list.size
|
||||
for j in (i + 1)...event.list.size
|
||||
if event.list[j].code == 108
|
||||
parts = event.list[j].parameters[0].split
|
||||
if parts.size != 1 && parts[0].downcase != "begin"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Based on version 2 by Near Fantastica, 04.01.06
|
||||
# In turn based on the Particle Engine designed by PinkMan
|
||||
class Particle_Engine
|
||||
def initialize(viewport = nil,map = nil)
|
||||
def initialize(viewport = nil, map = nil)
|
||||
@map = (map) ? map : $game_map
|
||||
@viewport = viewport
|
||||
@effect = []
|
||||
@@ -54,7 +54,7 @@ class Particle_Engine
|
||||
@effect.delete_at(event.id)
|
||||
end
|
||||
|
||||
def realloc_effect(event,particle)
|
||||
def realloc_effect(event, particle)
|
||||
type = pbEventCommentInput(event, 1, "Particle Engine Type")
|
||||
if type.nil?
|
||||
particle.dispose if particle
|
||||
@@ -68,13 +68,13 @@ class Particle_Engine
|
||||
end
|
||||
if !particle || !particle.is_a?(cls)
|
||||
particle.dispose if particle
|
||||
particle = cls.new(event,@viewport)
|
||||
particle = cls.new(event, @viewport)
|
||||
end
|
||||
return particle
|
||||
end
|
||||
|
||||
def pbParticleEffect(event)
|
||||
return realloc_effect(event,nil)
|
||||
return realloc_effect(event, nil)
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -91,7 +91,7 @@ class Particle_Engine
|
||||
if particle.event.pe_refresh
|
||||
event = particle.event
|
||||
event.pe_refresh = false
|
||||
particle = realloc_effect(event,particle)
|
||||
particle = realloc_effect(event, particle)
|
||||
@effect[i] = particle
|
||||
end
|
||||
particle.update if particle
|
||||
@@ -153,21 +153,21 @@ class ParticleSprite
|
||||
def update
|
||||
w = Graphics.width
|
||||
h = Graphics.height
|
||||
if !@sprite && @x>=@minleft && @y>=@mintop && @x<w && @y<h
|
||||
if !@sprite && @x >= @minleft && @y >= @mintop && @x < w && @y < h
|
||||
@sprite = Sprite.new(@viewport)
|
||||
elsif @sprite && (@x<@minleft || @y<@mintop || @x>=w || @y>=h)
|
||||
elsif @sprite && (@x < @minleft || @y < @mintop || @x >= w || @y >= h)
|
||||
@sprite.dispose
|
||||
@sprite = nil
|
||||
end
|
||||
if @sprite
|
||||
@sprite.x = @x if @sprite.x!=@x
|
||||
@sprite.x = @x if @sprite.x != @x
|
||||
@sprite.x -= @ox
|
||||
@sprite.y = @y if @sprite.y!=@y
|
||||
@sprite.y = @y if @sprite.y != @y
|
||||
@sprite.y -= @oy
|
||||
@sprite.z = @z if @sprite.z!=@z
|
||||
@sprite.opacity = @opacity if @sprite.opacity!=@opacity
|
||||
@sprite.blend_type = @blend_type if @sprite.blend_type!=@blend_type
|
||||
@sprite.bitmap = @bitmap if @sprite.bitmap!=@bitmap
|
||||
@sprite.z = @z if @sprite.z != @z
|
||||
@sprite.opacity = @opacity if @sprite.opacity != @opacity
|
||||
@sprite.blend_type = @blend_type if @sprite.blend_type != @blend_type
|
||||
@sprite.bitmap = @bitmap if @sprite.bitmap != @bitmap
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -177,7 +177,7 @@ end
|
||||
class ParticleEffect_Event < ParticleEffect
|
||||
attr_accessor :event
|
||||
|
||||
def initialize(event,viewport = nil)
|
||||
def initialize(event, viewport = nil)
|
||||
@event = event
|
||||
@viewport = viewport
|
||||
@particles = []
|
||||
@@ -185,24 +185,24 @@ class ParticleEffect_Event < ParticleEffect
|
||||
end
|
||||
|
||||
def setParameters(params)
|
||||
@randomhue,@leftright,@fade,
|
||||
@maxparticless,@hue,@slowdown,
|
||||
@ytop,@ybottom,@xleft,@xright,
|
||||
@xgravity,@ygravity,@xoffset,@yoffset,
|
||||
@opacityvar,@originalopacity = params
|
||||
@randomhue, @leftright, @fade,
|
||||
@maxparticless, @hue, @slowdown,
|
||||
@ytop, @ybottom, @xleft, @xright,
|
||||
@xgravity, @ygravity, @xoffset, @yoffset,
|
||||
@opacityvar, @originalopacity = params
|
||||
end
|
||||
|
||||
def loadBitmap(filename,hue)
|
||||
key = [filename,hue]
|
||||
def loadBitmap(filename, hue)
|
||||
key = [filename, hue]
|
||||
bitmap = @bitmaps[key]
|
||||
if !bitmap || bitmap.disposed?
|
||||
bitmap = AnimatedBitmap.new("Graphics/Fogs/"+filename,hue).deanimate
|
||||
bitmap = AnimatedBitmap.new("Graphics/Fogs/" + filename, hue).deanimate
|
||||
@bitmaps[key] = bitmap
|
||||
end
|
||||
return bitmap
|
||||
end
|
||||
|
||||
def initParticles(filename,opacity,zOffset = 0,blendtype = 1)
|
||||
def initParticles(filename, opacity, zOffset = 0, blendtype = 1)
|
||||
@particles = []
|
||||
@particlex = []
|
||||
@particley = []
|
||||
@@ -222,15 +222,15 @@ class ParticleEffect_Event < ParticleEffect
|
||||
@particley[i] = -@yoffset
|
||||
@particles[i] = ParticleSprite.new(@viewport)
|
||||
@particles[i].bitmap = loadBitmap(filename, @hue) if filename
|
||||
if i==0 && @particles[i].bitmap
|
||||
if i == 0 && @particles[i].bitmap
|
||||
@bmwidth = @particles[i].bitmap.width
|
||||
@bmheight = @particles[i].bitmap.height
|
||||
end
|
||||
@particles[i].blend_type = blendtype
|
||||
@particles[i].y = @startingy
|
||||
@particles[i].x = @startingx
|
||||
@particles[i].z = self.z+zOffset
|
||||
@opacity[i] = rand(opacity/4)
|
||||
@particles[i].z = self.z + zOffset
|
||||
@opacity[i] = rand(opacity / 4)
|
||||
@particles[i].opacity = @opacity[i]
|
||||
@particles[i].update
|
||||
end
|
||||
@@ -253,28 +253,28 @@ class ParticleEffect_Event < ParticleEffect
|
||||
newRealY = @event.real_y
|
||||
@startingx = selfX + @xoffset
|
||||
@startingy = selfY + @yoffset
|
||||
@__offsetx = (@real_x==newRealX) ? 0 : selfX-@screen_x
|
||||
@__offsety = (@real_y==newRealY) ? 0 : selfY-@screen_y
|
||||
@__offsetx = (@real_x == newRealX) ? 0 : selfX - @screen_x
|
||||
@__offsety = (@real_y == newRealY) ? 0 : selfY - @screen_y
|
||||
@screen_x = selfX
|
||||
@screen_y = selfY
|
||||
@real_x = newRealX
|
||||
@real_y = newRealY
|
||||
if @opacityvar>0 && @viewport
|
||||
opac = 255.0/@opacityvar
|
||||
minX = opac*(-@xgravity*1.0 / @slowdown).floor + @startingx
|
||||
maxX = opac*(@xgravity*1.0 / @slowdown).floor + @startingx
|
||||
minY = opac*(-@ygravity*1.0 / @slowdown).floor + @startingy
|
||||
if @opacityvar > 0 && @viewport
|
||||
opac = 255.0 / @opacityvar
|
||||
minX = opac * (-@xgravity * 1.0 / @slowdown).floor + @startingx
|
||||
maxX = opac * (@xgravity * 1.0 / @slowdown).floor + @startingx
|
||||
minY = opac * (-@ygravity * 1.0 / @slowdown).floor + @startingy
|
||||
maxY = @startingy
|
||||
minX -= @bmwidth
|
||||
minY -= @bmheight
|
||||
maxX += @bmwidth
|
||||
maxY += @bmheight
|
||||
if maxX<0 || maxY<0 || minX>=Graphics.width || minY>=Graphics.height
|
||||
if maxX < 0 || maxY < 0 || minX >= Graphics.width || minY >= Graphics.height
|
||||
# echo "skipped"
|
||||
return
|
||||
end
|
||||
end
|
||||
particleZ = selfZ+@zoffset
|
||||
particleZ = selfZ + @zoffset
|
||||
for i in 0...@maxparticless
|
||||
@particles[i].z = particleZ
|
||||
if @particles[i].y <= @ytop
|
||||
@@ -333,19 +333,19 @@ class ParticleEffect_Event < ParticleEffect
|
||||
def calcParticlePos(i)
|
||||
@leftright = rand(2)
|
||||
if @leftright == 1
|
||||
xo = -@xgravity*1.0 / @slowdown
|
||||
xo = -@xgravity * 1.0 / @slowdown
|
||||
else
|
||||
xo = @xgravity*1.0 / @slowdown
|
||||
xo = @xgravity * 1.0 / @slowdown
|
||||
end
|
||||
yo = -@ygravity*1.0 / @slowdown
|
||||
yo = -@ygravity * 1.0 / @slowdown
|
||||
@particlex[i] += xo
|
||||
@particley[i] += yo
|
||||
@particlex[i] -= @__offsetx
|
||||
@particley[i] -= @__offsety
|
||||
@particlex[i] = @particlex[i].floor
|
||||
@particley[i] = @particley[i].floor
|
||||
@particles[i].x = @particlex[i]+@startingx+@xoffset
|
||||
@particles[i].y = @particley[i]+@startingy+@yoffset
|
||||
@particles[i].x = @particlex[i] + @startingx + @xoffset
|
||||
@particles[i].y = @particley[i] + @startingy + @yoffset
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -363,33 +363,33 @@ end
|
||||
|
||||
|
||||
class Particle_Engine::Fire < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,1,20,40,0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0])
|
||||
initParticles("particle",250)
|
||||
setParameters([0, 0, 1, 20, 40, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
|
||||
initParticles("particle", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Smoke < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,0,80,20,0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80])
|
||||
initParticles("smoke",250)
|
||||
setParameters([0, 0, 0, 80, 20, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
|
||||
initParticles("smoke", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Teleport < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([1,1,1,10,rand(360),1,-64,
|
||||
Graphics.height,-64,Graphics.width,0,3,-8,-15,20,0])
|
||||
initParticles("wideportal",250)
|
||||
setParameters([1, 1, 1, 10, rand(360), 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 0, 3, -8, -15, 20, 0])
|
||||
initParticles("wideportal", 250)
|
||||
for i in 0...@maxparticless
|
||||
@particles[i].ox = 16
|
||||
@particles[i].oy = 16
|
||||
@@ -400,55 +400,55 @@ end
|
||||
|
||||
|
||||
class Particle_Engine::Spirit < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([1,0,1,20,rand(360),0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0])
|
||||
initParticles("particle",250)
|
||||
setParameters([1, 0, 1, 20, rand(360), 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
|
||||
initParticles("particle", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Explosion < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,1,20,0,0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0])
|
||||
initParticles("explosion",250)
|
||||
setParameters([0, 0, 1, 20, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0])
|
||||
initParticles("explosion", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Aura < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,1,20,0,1,-64,
|
||||
Graphics.height,-64,Graphics.width,2,2,-5,-13,30,0])
|
||||
initParticles("particle",250)
|
||||
setParameters([0, 0, 1, 20, 0, 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 2, 2, -5, -13, 30, 0])
|
||||
initParticles("particle", 250)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Soot < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,0,20,0,0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80])
|
||||
initParticles("smoke",100,0,2)
|
||||
setParameters([0, 0, 0, 20, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
|
||||
initParticles("smoke", 100, 0, 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::SootSmoke < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,0,30,0,0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80])
|
||||
initParticles("smoke",100,0)
|
||||
setParameters([0, 0, 0, 30, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80])
|
||||
initParticles("smoke", 100, 0)
|
||||
for i in 0...@maxparticless
|
||||
@particles[i].blend_type = rand(6) < 3 ? 1 : 2
|
||||
end
|
||||
@@ -458,22 +458,22 @@ end
|
||||
|
||||
|
||||
class Particle_Engine::Rocket < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,0,60,0,0.5,-64,
|
||||
Graphics.height,-64,Graphics.width,0.5,0,-5,-15,5,80])
|
||||
initParticles("smoke",100,-1)
|
||||
setParameters([0, 0, 0, 60, 0, 0.5, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.5, 0, -5, -15, 5, 80])
|
||||
initParticles("smoke", 100, -1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::FixedTeleport < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([1,0,1,10,rand(360),1,
|
||||
-Graphics.height,Graphics.height,0,Graphics.width,0,3,-8,-15,20,0])
|
||||
initParticles("wideportal",250)
|
||||
setParameters([1, 0, 1, 10, rand(360), 1,
|
||||
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 20, 0])
|
||||
initParticles("wideportal", 250)
|
||||
for i in 0...@maxparticless
|
||||
@particles[i].ox = 16
|
||||
@particles[i].oy = 16
|
||||
@@ -485,11 +485,11 @@ end
|
||||
|
||||
# By Peter O.
|
||||
class Particle_Engine::StarTeleport < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,1,10,0,1,
|
||||
-Graphics.height,Graphics.height,0,Graphics.width,0,3,-8,-15,10,0])
|
||||
initParticles("star",250)
|
||||
setParameters([0, 0, 1, 10, 0, 1,
|
||||
-Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 10, 0])
|
||||
initParticles("star", 250)
|
||||
for i in 0...@maxparticless
|
||||
@particles[i].ox = 48
|
||||
@particles[i].oy = 48
|
||||
@@ -500,59 +500,59 @@ end
|
||||
|
||||
|
||||
class Particle_Engine::Smokescreen < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,0,250,0,0.2,-64,
|
||||
Graphics.height,-64,Graphics.width,0.8,0.8,-5,-15,5,80])
|
||||
initParticles(nil,100)
|
||||
setParameters([0, 0, 0, 250, 0, 0.2, -64,
|
||||
Graphics.height, -64, Graphics.width, 0.8, 0.8, -5, -15, 5, 80])
|
||||
initParticles(nil, 100)
|
||||
for i in 0...@maxparticless
|
||||
rnd = rand(3)
|
||||
@opacity[i] = (rnd==0) ? 1 : 100
|
||||
filename = (rnd==0) ? "explosionsmoke" : "smoke"
|
||||
@opacity[i] = (rnd == 0) ? 1 : 100
|
||||
filename = (rnd == 0) ? "explosionsmoke" : "smoke"
|
||||
@particles[i].bitmap = loadBitmap(filename, @hue)
|
||||
end
|
||||
end
|
||||
|
||||
def calcParticlePos(i)
|
||||
if @randomhue==1
|
||||
filename = (rand(3)==0) ? "explosionsmoke" : "smoke"
|
||||
if @randomhue == 1
|
||||
filename = (rand(3) == 0) ? "explosionsmoke" : "smoke"
|
||||
@particles[i].bitmap = loadBitmap(filename, @hue)
|
||||
end
|
||||
multiple = 1.7
|
||||
xgrav = @xgravity*multiple/@slowdown
|
||||
xgrav = -xgrav if (rand(2)==1)
|
||||
ygrav = @ygravity*multiple/@slowdown
|
||||
ygrav = -ygrav if (rand(2)==1)
|
||||
xgrav = @xgravity * multiple / @slowdown
|
||||
xgrav = -xgrav if (rand(2) == 1)
|
||||
ygrav = @ygravity * multiple / @slowdown
|
||||
ygrav = -ygrav if (rand(2) == 1)
|
||||
@particlex[i] += xgrav
|
||||
@particley[i] += ygrav
|
||||
@particlex[i] -= @__offsetx
|
||||
@particley[i] -= @__offsety
|
||||
@particlex[i] = @particlex[i].floor
|
||||
@particley[i] = @particley[i].floor
|
||||
@particles[i].x = @particlex[i]+@startingx+@xoffset
|
||||
@particles[i].y = @particley[i]+@startingy+@yoffset
|
||||
@particles[i].x = @particlex[i] + @startingx + @xoffset
|
||||
@particles[i].y = @particley[i] + @startingy + @yoffset
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Flare < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,1,30,10,1,-64,
|
||||
Graphics.height,-64,Graphics.width,2,2,-5,-12,30,0])
|
||||
initParticles("particle",255)
|
||||
setParameters([0, 0, 1, 30, 10, 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 2, 2, -5, -12, 30, 0])
|
||||
initParticles("particle", 255)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Particle_Engine::Splash < ParticleEffect_Event
|
||||
def initialize(event,viewport)
|
||||
def initialize(event, viewport)
|
||||
super
|
||||
setParameters([0,0,1,30,255,1,-64,
|
||||
Graphics.height,-64,Graphics.width,4,2,-5,-12,30,0])
|
||||
initParticles("smoke",50)
|
||||
setParameters([0, 0, 1, 30, 255, 1, -64,
|
||||
Graphics.height, -64, Graphics.width, 4, 2, -5, -12, 30, 0])
|
||||
initParticles("smoke", 50)
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -570,7 +570,7 @@ class Game_Event < Game_Character
|
||||
attr_accessor :pe_refresh
|
||||
|
||||
alias nf_particles_game_map_initialize initialize
|
||||
def initialize(map_id,event,map = nil)
|
||||
def initialize(map_id, event, map = nil)
|
||||
@pe_refresh = false
|
||||
begin
|
||||
nf_particles_game_map_initialize(map_id, event, map)
|
||||
|
||||
@@ -37,7 +37,7 @@ end
|
||||
|
||||
|
||||
|
||||
def getCubicPoint2(src,t)
|
||||
def getCubicPoint2(src, t)
|
||||
x0 = src[0]
|
||||
y0 = src[1]
|
||||
cx0 = src[2]
|
||||
@@ -47,29 +47,29 @@ def getCubicPoint2(src,t)
|
||||
x1 = src[6]
|
||||
y1 = src[7]
|
||||
|
||||
x1 = cx1+(x1-cx1)*t
|
||||
x0 = x0+(cx0-x0)*t
|
||||
cx0 = cx0+(cx1-cx0)*t
|
||||
cx1 = cx0+(x1-cx0)*t
|
||||
cx0 = x0+(cx0-x0)*t
|
||||
cx = cx0+(cx1-cx0)*t
|
||||
x1 = cx1 + (x1 - cx1) * t
|
||||
x0 = x0 + (cx0 - x0) * t
|
||||
cx0 = cx0 + (cx1 - cx0) * t
|
||||
cx1 = cx0 + (x1 - cx0) * t
|
||||
cx0 = x0 + (cx0 - x0) * t
|
||||
cx = cx0 + (cx1 - cx0) * t
|
||||
# a = x1 - 3 * cx1 + 3 * cx0 - x0
|
||||
# b = 3 * (cx1 - 2 * cx0 + x0)
|
||||
# c = 3 * (cx0 - x0)
|
||||
# d = x0
|
||||
# cx = a*t*t*t + b*t*t + c*t + d
|
||||
y1 = cy1+(y1-cy1)*t
|
||||
y0 = y0+(cy0-y0)*t
|
||||
cy0 = cy0+(cy1-cy0)*t
|
||||
cy1 = cy0+(y1-cy0)*t
|
||||
cy0 = y0+(cy0-y0)*t
|
||||
cy = cy0+(cy1-cy0)*t
|
||||
y1 = cy1 + (y1 - cy1) * t
|
||||
y0 = y0 + (cy0 - y0) * t
|
||||
cy0 = cy0 + (cy1 - cy0) * t
|
||||
cy1 = cy0 + (y1 - cy0) * t
|
||||
cy0 = y0 + (cy0 - y0) * t
|
||||
cy = cy0 + (cy1 - cy0) * t
|
||||
# a = y1 - 3 * cy1 + 3 * cy0 - y0
|
||||
# b = 3 * (cy1 - 2 * cy0 + y0)
|
||||
# c = 3 * (cy0 - y0)
|
||||
# d = y0
|
||||
# cy = a*t*t*t + b*t*t + c*t + d
|
||||
return [cx,cy]
|
||||
return [cx, cy]
|
||||
end
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ class PictureEx
|
||||
@blend_type = 0
|
||||
@name = ""
|
||||
@origin = PictureOrigin::TopLeft
|
||||
@src_rect = Rect.new(0,0,-1,-1)
|
||||
@src_rect = Rect.new(0, 0, -1, -1)
|
||||
@cropBottom = -1
|
||||
@frameUpdates = []
|
||||
end
|
||||
@@ -132,28 +132,28 @@ class PictureEx
|
||||
|
||||
def setCallback(delay, cb = nil)
|
||||
delay = ensureDelayAndDuration(delay)
|
||||
@processes.push([nil,delay,0,0,cb])
|
||||
@processes.push([nil, delay, 0, 0, cb])
|
||||
end
|
||||
|
||||
def running?
|
||||
return @processes.length>0
|
||||
return @processes.length > 0
|
||||
end
|
||||
|
||||
def totalDuration
|
||||
ret = 0
|
||||
for process in @processes
|
||||
dur = process[1]+process[2]
|
||||
ret = dur if dur>ret
|
||||
dur = process[1] + process[2]
|
||||
ret = dur if dur > ret
|
||||
end
|
||||
ret *= 20.0/Graphics.frame_rate
|
||||
ret *= 20.0 / Graphics.frame_rate
|
||||
return ret.to_i
|
||||
end
|
||||
|
||||
def ensureDelayAndDuration(delay, duration = nil)
|
||||
delay = self.totalDuration if delay<0
|
||||
delay *= Graphics.frame_rate/20.0
|
||||
delay = self.totalDuration if delay < 0
|
||||
delay *= Graphics.frame_rate / 20.0
|
||||
if !duration.nil?
|
||||
duration *= Graphics.frame_rate/20.0
|
||||
duration *= Graphics.frame_rate / 20.0
|
||||
return delay.to_i, duration.to_i
|
||||
end
|
||||
return delay.to_i
|
||||
@@ -169,8 +169,8 @@ class PictureEx
|
||||
# point. If you make a sprite auto-rotate, you should not try to alter
|
||||
# the angle another way too.
|
||||
def rotate(speed)
|
||||
@rotate_speed = speed*20.0/Graphics.frame_rate
|
||||
while @rotate_speed<0
|
||||
@rotate_speed = speed * 20.0 / Graphics.frame_rate
|
||||
while @rotate_speed < 0
|
||||
@rotate_speed += 360
|
||||
end
|
||||
@rotate_speed %= 360
|
||||
@@ -186,7 +186,7 @@ class PictureEx
|
||||
|
||||
def adjustPosition(xOffset, yOffset)
|
||||
for process in @processes
|
||||
next if process[0]!=Processes::XY
|
||||
next if process[0] != Processes::XY
|
||||
process[5] += xOffset
|
||||
process[6] += yOffset
|
||||
process[7] += xOffset
|
||||
@@ -195,150 +195,150 @@ class PictureEx
|
||||
end
|
||||
|
||||
def move(delay, duration, origin, x, y, zoom_x = 100.0, zoom_y = 100.0, opacity = 255)
|
||||
setOrigin(delay,duration,origin)
|
||||
moveXY(delay,duration,x,y)
|
||||
moveZoomXY(delay,duration,zoom_x,zoom_y)
|
||||
moveOpacity(delay,duration,opacity)
|
||||
setOrigin(delay, duration, origin)
|
||||
moveXY(delay, duration, x, y)
|
||||
moveZoomXY(delay, duration, zoom_x, zoom_y)
|
||||
moveOpacity(delay, duration, opacity)
|
||||
end
|
||||
|
||||
def moveXY(delay, duration, x, y, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::XY,delay,duration,0,cb,@x,@y,x,y])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::XY, delay, duration, 0, cb, @x, @y, x, y])
|
||||
end
|
||||
|
||||
def setXY(delay, x, y, cb = nil)
|
||||
moveXY(delay,0,x,y,cb)
|
||||
moveXY(delay, 0, x, y, cb)
|
||||
end
|
||||
|
||||
def moveCurve(delay, duration, x1, y1, x2, y2, x3, y3, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Curve,delay,duration,0,cb,[@x,@y,x1,y1,x2,y2,x3,y3]])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::Curve, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]])
|
||||
end
|
||||
|
||||
def moveDelta(delay, duration, x, y, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::DeltaXY,delay,duration,0,cb,@x,@y,x,y])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::DeltaXY, delay, duration, 0, cb, @x, @y, x, y])
|
||||
end
|
||||
|
||||
def setDelta(delay, x, y, cb = nil)
|
||||
moveDelta(delay,0,x,y,cb)
|
||||
moveDelta(delay, 0, x, y, cb)
|
||||
end
|
||||
|
||||
def moveZ(delay, duration, z, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Z,delay,duration,0,cb,@z,z])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::Z, delay, duration, 0, cb, @z, z])
|
||||
end
|
||||
|
||||
def setZ(delay, z, cb = nil)
|
||||
moveZ(delay,0,z,cb)
|
||||
moveZ(delay, 0, z, cb)
|
||||
end
|
||||
|
||||
def moveZoomXY(delay, duration, zoom_x, zoom_y, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Zoom,delay,duration,0,cb,@zoom_x,@zoom_y,zoom_x,zoom_y])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::Zoom, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y])
|
||||
end
|
||||
|
||||
def setZoomXY(delay, zoom_x, zoom_y, cb = nil)
|
||||
moveZoomXY(delay,0,zoom_x,zoom_y,cb)
|
||||
moveZoomXY(delay, 0, zoom_x, zoom_y, cb)
|
||||
end
|
||||
|
||||
def moveZoom(delay, duration, zoom, cb = nil)
|
||||
moveZoomXY(delay,duration,zoom,zoom,cb)
|
||||
moveZoomXY(delay, duration, zoom, zoom, cb)
|
||||
end
|
||||
|
||||
def setZoom(delay, zoom, cb = nil)
|
||||
moveZoomXY(delay,0,zoom,zoom,cb)
|
||||
moveZoomXY(delay, 0, zoom, zoom, cb)
|
||||
end
|
||||
|
||||
def moveAngle(delay, duration, angle, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Angle,delay,duration,0,cb,@angle,angle])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::Angle, delay, duration, 0, cb, @angle, angle])
|
||||
end
|
||||
|
||||
def setAngle(delay, angle, cb = nil)
|
||||
moveAngle(delay,0,angle,cb)
|
||||
moveAngle(delay, 0, angle, cb)
|
||||
end
|
||||
|
||||
def moveTone(delay, duration, tone, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
target = (tone) ? tone.clone : Tone.new(0,0,0,0)
|
||||
@processes.push([Processes::Tone,delay,duration,0,cb,@tone.clone,target])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
target = (tone) ? tone.clone : Tone.new(0, 0, 0, 0)
|
||||
@processes.push([Processes::Tone, delay, duration, 0, cb, @tone.clone, target])
|
||||
end
|
||||
|
||||
def setTone(delay, tone, cb = nil)
|
||||
moveTone(delay,0,tone,cb)
|
||||
moveTone(delay, 0, tone, cb)
|
||||
end
|
||||
|
||||
def moveColor(delay, duration, color, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
target = (color) ? color.clone : Color.new(0,0,0,0)
|
||||
@processes.push([Processes::Color,delay,duration,0,cb,@color.clone,target])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
target = (color) ? color.clone : Color.new(0, 0, 0, 0)
|
||||
@processes.push([Processes::Color, delay, duration, 0, cb, @color.clone, target])
|
||||
end
|
||||
|
||||
def setColor(delay, color, cb = nil)
|
||||
moveColor(delay,0,color,cb)
|
||||
moveColor(delay, 0, color, cb)
|
||||
end
|
||||
|
||||
# Hue changes don't actually work.
|
||||
def moveHue(delay, duration, hue, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Hue,delay,duration,0,cb,@hue,hue])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::Hue, delay, duration, 0, cb, @hue, hue])
|
||||
end
|
||||
|
||||
# Hue changes don't actually work.
|
||||
def setHue(delay, hue, cb = nil)
|
||||
moveHue(delay,0,hue,cb)
|
||||
moveHue(delay, 0, hue, cb)
|
||||
end
|
||||
|
||||
def moveOpacity(delay, duration, opacity, cb = nil)
|
||||
delay, duration = ensureDelayAndDuration(delay,duration)
|
||||
@processes.push([Processes::Opacity,delay,duration,0,cb,@opacity,opacity])
|
||||
delay, duration = ensureDelayAndDuration(delay, duration)
|
||||
@processes.push([Processes::Opacity, delay, duration, 0, cb, @opacity, opacity])
|
||||
end
|
||||
|
||||
def setOpacity(delay, opacity, cb = nil)
|
||||
moveOpacity(delay,0,opacity,cb)
|
||||
moveOpacity(delay, 0, opacity, cb)
|
||||
end
|
||||
|
||||
def setVisible(delay, visible, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Visible,delay,0,0,cb,visible])
|
||||
@processes.push([Processes::Visible, delay, 0, 0, cb, visible])
|
||||
end
|
||||
|
||||
# Only values of 0 (normal), 1 (additive) and 2 (subtractive) are allowed.
|
||||
def setBlendType(delay, blend, cb = nil)
|
||||
delay = ensureDelayAndDuration(delay)
|
||||
@processes.push([Processes::BlendType,delay,0,0,cb,blend])
|
||||
@processes.push([Processes::BlendType, delay, 0, 0, cb, blend])
|
||||
end
|
||||
|
||||
def setSE(delay, seFile, volume = nil, pitch = nil, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::SE,delay,0,0,cb,seFile,volume,pitch])
|
||||
@processes.push([Processes::SE, delay, 0, 0, cb, seFile, volume, pitch])
|
||||
end
|
||||
|
||||
def setName(delay, name, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Name,delay,0,0,cb,name])
|
||||
@processes.push([Processes::Name, delay, 0, 0, cb, name])
|
||||
end
|
||||
|
||||
def setOrigin(delay, origin, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Origin,delay,0,0,cb,origin])
|
||||
@processes.push([Processes::Origin, delay, 0, 0, cb, origin])
|
||||
end
|
||||
|
||||
def setSrc(delay, srcX, srcY, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::Src,delay,0,0,cb,srcX,srcY])
|
||||
@processes.push([Processes::Src, delay, 0, 0, cb, srcX, srcY])
|
||||
end
|
||||
|
||||
def setSrcSize(delay, srcWidth, srcHeight, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::SrcSize,delay,0,0,cb,srcWidth,srcHeight])
|
||||
@processes.push([Processes::SrcSize, delay, 0, 0, cb, srcWidth, srcHeight])
|
||||
end
|
||||
|
||||
# Used to cut Pokémon sprites off when they faint and sink into the ground.
|
||||
def setCropBottom(delay, y, cb = nil)
|
||||
delay = ensureDelay(delay)
|
||||
@processes.push([Processes::CropBottom,delay,0,0,cb,y])
|
||||
@processes.push([Processes::CropBottom, delay, 0, 0, cb, y])
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -347,9 +347,9 @@ class PictureEx
|
||||
for i in 0...@processes.length
|
||||
process = @processes[i]
|
||||
# Decrease delay of processes that are scheduled to start later
|
||||
if process[1]>=0
|
||||
if process[1] >= 0
|
||||
# Set initial values if the process will start this frame
|
||||
if process[1]==0
|
||||
if process[1] == 0
|
||||
case process[0]
|
||||
when Processes::XY
|
||||
process[5] = @x
|
||||
@@ -382,18 +382,18 @@ class PictureEx
|
||||
# Decrease delay counter
|
||||
process[1] -= 1
|
||||
# Process hasn't started yet, skip to the next one
|
||||
next if process[1]>=0
|
||||
next if process[1] >= 0
|
||||
end
|
||||
# Update process
|
||||
@frameUpdates.push(process[0]) if !@frameUpdates.include?(process[0])
|
||||
fra = (process[2]==0) ? 1 : process[3] # Frame counter
|
||||
dur = (process[2]==0) ? 1 : process[2] # Total duration of process
|
||||
fra = (process[2] == 0) ? 1 : process[3] # Frame counter
|
||||
dur = (process[2] == 0) ? 1 : process[2] # Total duration of process
|
||||
case process[0]
|
||||
when Processes::XY, Processes::DeltaXY
|
||||
@x = process[5] + fra * (process[7] - process[5]) / dur
|
||||
@y = process[6] + fra * (process[8] - process[6]) / dur
|
||||
when Processes::Curve
|
||||
@x, @y = getCubicPoint2(process[5],fra.to_f/dur)
|
||||
@x, @y = getCubicPoint2(process[5], fra.to_f / dur)
|
||||
when Processes::Z
|
||||
@z = process[5] + fra * (process[6] - process[5]) / dur
|
||||
when Processes::Zoom
|
||||
@@ -420,7 +420,7 @@ class PictureEx
|
||||
when Processes::BlendType
|
||||
@blend_type = process[5]
|
||||
when Processes::SE
|
||||
pbSEPlay(process[5],process[6],process[7])
|
||||
pbSEPlay(process[5], process[6], process[7])
|
||||
when Processes::Name
|
||||
@name = process[5]
|
||||
when Processes::Origin
|
||||
@@ -436,7 +436,7 @@ class PictureEx
|
||||
end
|
||||
# Increase frame counter
|
||||
process[3] += 1
|
||||
if process[3]>process[2]
|
||||
if process[3] > process[2]
|
||||
# Process has ended, erase it
|
||||
callback(process[4]) if process[4]
|
||||
@processes[i] = nil
|
||||
@@ -449,7 +449,7 @@ class PictureEx
|
||||
if @rotate_speed != 0
|
||||
@frameUpdates.push(Processes::Angle) if !@frameUpdates.include?(Processes::Angle)
|
||||
@angle += @rotate_speed
|
||||
while @angle<0
|
||||
while @angle < 0
|
||||
@angle += 360
|
||||
end
|
||||
@angle %= 360
|
||||
@@ -463,7 +463,7 @@ end
|
||||
#
|
||||
#===============================================================================
|
||||
def setPictureSprite(sprite, picture, iconSprite = false)
|
||||
return if picture.frameUpdates.length==0
|
||||
return if picture.frameUpdates.length == 0
|
||||
for i in 0...picture.frameUpdates.length
|
||||
case picture.frameUpdates[i]
|
||||
when Processes::XY, Processes::DeltaXY
|
||||
@@ -495,7 +495,7 @@ def setPictureSprite(sprite, picture, iconSprite = false)
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
|
||||
sprite.ox = 0
|
||||
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
|
||||
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width/2 : 0
|
||||
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width / 2 : 0
|
||||
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
|
||||
sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width : 0
|
||||
end
|
||||
@@ -503,7 +503,7 @@ def setPictureSprite(sprite, picture, iconSprite = false)
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
|
||||
sprite.oy = 0
|
||||
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
|
||||
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height/2 : 0
|
||||
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height / 2 : 0
|
||||
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
|
||||
sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height : 0
|
||||
end
|
||||
@@ -517,14 +517,14 @@ def setPictureSprite(sprite, picture, iconSprite = false)
|
||||
sprite.src_rect.height = picture.src_rect.height
|
||||
end
|
||||
end
|
||||
if iconSprite && sprite.src_rect && picture.cropBottom>=0
|
||||
spriteBottom = sprite.y-sprite.oy+sprite.src_rect.height
|
||||
if spriteBottom>picture.cropBottom
|
||||
sprite.src_rect.height = [picture.cropBottom-sprite.y+sprite.oy,0].max
|
||||
if iconSprite && sprite.src_rect && picture.cropBottom >= 0
|
||||
spriteBottom = sprite.y - sprite.oy + sprite.src_rect.height
|
||||
if spriteBottom > picture.cropBottom
|
||||
sprite.src_rect.height = [picture.cropBottom - sprite.y + sprite.oy, 0].max
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def setPictureIconSprite(sprite, picture)
|
||||
setPictureSprite(sprite,picture,true)
|
||||
setPictureSprite(sprite, picture, true)
|
||||
end
|
||||
|
||||
@@ -19,24 +19,24 @@ class Interpolator
|
||||
return @tweening
|
||||
end
|
||||
|
||||
def tween(sprite,items,frames)
|
||||
def tween(sprite, items, frames)
|
||||
@tweensteps = []
|
||||
if sprite && !sprite.disposed? && frames>0
|
||||
if sprite && !sprite.disposed? && frames > 0
|
||||
@frames = frames
|
||||
@step = 0
|
||||
@sprite = sprite
|
||||
for item in items
|
||||
case item[0]
|
||||
when ZOOM_X
|
||||
@tweensteps[item[0]] = [sprite.zoom_x,item[1]-sprite.zoom_x]
|
||||
@tweensteps[item[0]] = [sprite.zoom_x, item[1] - sprite.zoom_x]
|
||||
when ZOOM_Y
|
||||
@tweensteps[item[0]] = [sprite.zoom_y,item[1]-sprite.zoom_y]
|
||||
@tweensteps[item[0]] = [sprite.zoom_y, item[1] - sprite.zoom_y]
|
||||
when X
|
||||
@tweensteps[item[0]] = [sprite.x,item[1]-sprite.x]
|
||||
@tweensteps[item[0]] = [sprite.x, item[1] - sprite.x]
|
||||
when Y
|
||||
@tweensteps[item[0]] = [sprite.y,item[1]-sprite.y]
|
||||
@tweensteps[item[0]] = [sprite.y, item[1] - sprite.y]
|
||||
when OPACITY
|
||||
@tweensteps[item[0]] = [sprite.opacity,item[1]-sprite.opacity]
|
||||
@tweensteps[item[0]] = [sprite.opacity, item[1] - sprite.opacity]
|
||||
when COLOR
|
||||
@tweensteps[item[0]] = [sprite.color.clone,
|
||||
Color.new(item[1].red - sprite.color.red,
|
||||
@@ -51,21 +51,21 @@ class Interpolator
|
||||
|
||||
def update
|
||||
if @tweening
|
||||
t = (@step*1.0)/@frames
|
||||
t = (@step * 1.0) / @frames
|
||||
for i in 0...@tweensteps.length
|
||||
item = @tweensteps[i]
|
||||
next if !item
|
||||
case i
|
||||
when ZOOM_X
|
||||
@sprite.zoom_x = item[0]+item[1]*t
|
||||
@sprite.zoom_x = item[0] + item[1] * t
|
||||
when ZOOM_Y
|
||||
@sprite.zoom_y = item[0]+item[1]*t
|
||||
@sprite.zoom_y = item[0] + item[1] * t
|
||||
when X
|
||||
@sprite.x = item[0]+item[1]*t
|
||||
@sprite.x = item[0] + item[1] * t
|
||||
when Y
|
||||
@sprite.y = item[0]+item[1]*t
|
||||
@sprite.y = item[0] + item[1] * t
|
||||
when OPACITY
|
||||
@sprite.opacity = item[0]+item[1]*t
|
||||
@sprite.opacity = item[0] + item[1] * t
|
||||
when COLOR
|
||||
@sprite.color = Color.new(item[0].red + item[1].red * t,
|
||||
item[0].green + item[1].green * t,
|
||||
@@ -74,7 +74,7 @@ class Interpolator
|
||||
end
|
||||
end
|
||||
@step += 1
|
||||
if @step==@frames
|
||||
if @step == @frames
|
||||
@step = 0
|
||||
@frames = 0
|
||||
@tweening = false
|
||||
@@ -86,46 +86,46 @@ end
|
||||
|
||||
|
||||
class RectInterpolator
|
||||
def initialize(oldrect,newrect,frames)
|
||||
restart(oldrect,newrect,frames)
|
||||
def initialize(oldrect, newrect, frames)
|
||||
restart(oldrect, newrect, frames)
|
||||
end
|
||||
|
||||
def restart(oldrect,newrect,frames)
|
||||
def restart(oldrect, newrect, frames)
|
||||
@oldrect = oldrect
|
||||
@newrect = newrect
|
||||
@frames = [frames,1].max
|
||||
@frames = [frames, 1].max
|
||||
@curframe = 0
|
||||
@rect = oldrect.clone
|
||||
end
|
||||
|
||||
def set(rect)
|
||||
rect.set(@rect.x,@rect.y,@rect.width,@rect.height)
|
||||
rect.set(@rect.x, @rect.y, @rect.width, @rect.height)
|
||||
end
|
||||
|
||||
def done?
|
||||
@curframe>@frames
|
||||
@curframe > @frames
|
||||
end
|
||||
|
||||
def update
|
||||
return if done?
|
||||
t = (@curframe*1.0/@frames)
|
||||
t = (@curframe * 1.0 / @frames)
|
||||
x1 = @oldrect.x
|
||||
x2 = @newrect.x
|
||||
x = x1+t*(x2-x1)
|
||||
x = x1 + t * (x2 - x1)
|
||||
y1 = @oldrect.y
|
||||
y2 = @newrect.y
|
||||
y = y1+t*(y2-y1)
|
||||
rx1 = @oldrect.x+@oldrect.width
|
||||
rx2 = @newrect.x+@newrect.width
|
||||
rx = rx1+t*(rx2-rx1)
|
||||
ry1 = @oldrect.y+@oldrect.height
|
||||
ry2 = @newrect.y+@newrect.height
|
||||
ry = ry1+t*(ry2-ry1)
|
||||
minx = x<rx ? x : rx
|
||||
maxx = x>rx ? x : rx
|
||||
miny = y<ry ? y : ry
|
||||
maxy = y>ry ? y : ry
|
||||
@rect.set(minx,miny,maxx-minx,maxy-miny)
|
||||
y = y1 + t * (y2 - y1)
|
||||
rx1 = @oldrect.x + @oldrect.width
|
||||
rx2 = @newrect.x + @newrect.width
|
||||
rx = rx1 + t * (rx2 - rx1)
|
||||
ry1 = @oldrect.y + @oldrect.height
|
||||
ry2 = @newrect.y + @newrect.height
|
||||
ry = ry1 + t * (ry2 - ry1)
|
||||
minx = x < rx ? x : rx
|
||||
maxx = x > rx ? x : rx
|
||||
miny = y < ry ? y : ry
|
||||
maxy = y > ry ? y : ry
|
||||
@rect.set(minx, miny, maxx - minx, maxy - miny)
|
||||
@curframe += 1
|
||||
end
|
||||
end
|
||||
@@ -136,11 +136,11 @@ class PointInterpolator
|
||||
attr_reader :x
|
||||
attr_reader :y
|
||||
|
||||
def initialize(oldx,oldy,newx,newy,frames)
|
||||
restart(oldx,oldy,newx,newy,frames)
|
||||
def initialize(oldx, oldy, newx, newy, frames)
|
||||
restart(oldx, oldy, newx, newy, frames)
|
||||
end
|
||||
|
||||
def restart(oldx,oldy,newx,newy,frames)
|
||||
def restart(oldx, oldy, newx, newy, frames)
|
||||
@oldx = oldx
|
||||
@oldy = oldy
|
||||
@newx = newx
|
||||
@@ -152,18 +152,18 @@ class PointInterpolator
|
||||
end
|
||||
|
||||
def done?
|
||||
@curframe>@frames
|
||||
@curframe > @frames
|
||||
end
|
||||
|
||||
def update
|
||||
return if done?
|
||||
t = (@curframe*1.0/@frames)
|
||||
t = (@curframe * 1.0 / @frames)
|
||||
rx1 = @oldx
|
||||
rx2 = @newx
|
||||
@x = rx1+t*(rx2-rx1)
|
||||
@x = rx1 + t * (rx2 - rx1)
|
||||
ry1 = @oldy
|
||||
ry2 = @newy
|
||||
@y = ry1+t*(ry2-ry1)
|
||||
@y = ry1 + t * (ry2 - ry1)
|
||||
@curframe += 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module ScreenPosHelper
|
||||
def self.pbScreenZoomX(ch)
|
||||
return Game_Map::TILE_WIDTH/32.0
|
||||
return Game_Map::TILE_WIDTH / 32.0
|
||||
end
|
||||
|
||||
def self.pbScreenZoomY(ch)
|
||||
return Game_Map::TILE_HEIGHT/32.0
|
||||
return Game_Map::TILE_HEIGHT / 32.0
|
||||
end
|
||||
|
||||
def self.pbScreenX(ch)
|
||||
@@ -15,29 +15,29 @@ module ScreenPosHelper
|
||||
return ch.screen_y
|
||||
end
|
||||
|
||||
@heightcache={}
|
||||
@heightcache = {}
|
||||
|
||||
def self.bmHeight(bm)
|
||||
h=@heightcache[bm]
|
||||
h = @heightcache[bm]
|
||||
if !h
|
||||
bmap=AnimatedBitmap.new("Graphics/Characters/"+bm,0)
|
||||
h=bmap.height
|
||||
@heightcache[bm]=h
|
||||
bmap = AnimatedBitmap.new("Graphics/Characters/" + bm, 0)
|
||||
h = bmap.height
|
||||
@heightcache[bm] = h
|
||||
bmap.dispose
|
||||
end
|
||||
return h
|
||||
end
|
||||
|
||||
def self.pbScreenZ(ch,height = nil)
|
||||
if height==nil
|
||||
height=0
|
||||
def self.pbScreenZ(ch, height = nil)
|
||||
if height == nil
|
||||
height = 0
|
||||
if ch.tile_id > 0
|
||||
height=32
|
||||
elsif ch.character_name!=""
|
||||
height=bmHeight(ch.character_name)/4
|
||||
height = 32
|
||||
elsif ch.character_name != ""
|
||||
height = bmHeight(ch.character_name) / 4
|
||||
end
|
||||
end
|
||||
ret=ch.screen_z(height)
|
||||
ret = ch.screen_z(height)
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user