From 8d1865e2f1dc52fd34f4e99ca776f97f2ef83b96 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sun, 14 Mar 2021 23:38:08 +0000 Subject: [PATCH] Changed overworld weather animations --- .../003_Game classes/001_Game_Screen.rb | 12 +- .../013_Overworld/004_PField_Weather.rb | 465 ++++++++++-------- 2 files changed, 272 insertions(+), 205 deletions(-) diff --git a/Data/Scripts/003_Game classes/001_Game_Screen.rb b/Data/Scripts/003_Game classes/001_Game_Screen.rb index 2db8a1121..9dc445b16 100644 --- a/Data/Scripts/003_Game classes/001_Game_Screen.rb +++ b/Data/Scripts/003_Game classes/001_Game_Screen.rb @@ -83,16 +83,14 @@ class Game_Screen #----------------------------------------------------------------------------- def weather(type, power, duration) @weather_type_target = type - if @weather_type_target!=0 - @weather_type = @weather_type_target - end - if @weather_type_target==0 + @weather_type = @weather_type_target if @weather_type_target != 0 + if @weather_type_target == 0 @weather_max_target = 0.0 else - @weather_max_target = (power + 1) * 4.0 + @weather_max_target = (power + 1) * RPG::Weather::MAX_SPRITES / 10 end - @weather_duration = duration - if @weather_duration==0 + @weather_duration = duration * Graphics.frame_rate / 20 + if @weather_duration == 0 @weather_type = @weather_type_target @weather_max = @weather_max_target end diff --git a/Data/Scripts/013_Overworld/004_PField_Weather.rb b/Data/Scripts/013_Overworld/004_PField_Weather.rb index 4d9e57f56..8e5642712 100644 --- a/Data/Scripts/013_Overworld/004_PField_Weather.rb +++ b/Data/Scripts/013_Overworld/004_PField_Weather.rb @@ -1,188 +1,66 @@ +# All weather particles are assumed to start at the top/right and move to the +# bottom/left. Particles are only reset if they are off-screen to the left or +# bottom. module RPG class Weather attr_reader :type attr_reader :max attr_reader :ox attr_reader :oy + MAX_SPRITES = 60 def initialize(viewport = nil) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = viewport.z + 1 + @origViewport = viewport @type = 0 @max = 0 @ox = 0 @oy = 0 - @sunValue = 0 + @tiles_wide = 0 + @tiles_tall = 0 @sun = 0 - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z = viewport.z+1 - @origViewport = viewport - # [array of bitmaps, +x per frame, +y per frame, +opacity per frame] + @sunValue = 0 + # [array of particle bitmaps, array of tile bitmaps, + # +x per frame (particle), +y per frame (particle), +opacity per frame (particle), + # +x per frame (tile), +y per frame (tile)] @weatherTypes = [] @weatherTypes[PBFieldWeather::None] = nil - @weatherTypes[PBFieldWeather::Rain] = [[], -6, 24, -8] - @weatherTypes[PBFieldWeather::HeavyRain] = [[], -24, 24, -4] - @weatherTypes[PBFieldWeather::Storm] = [[], -24, 24, -4] - @weatherTypes[PBFieldWeather::Snow] = [[], -4, 8, 0] - @weatherTypes[PBFieldWeather::Blizzard] = [[], -16, 16, -4] - @weatherTypes[PBFieldWeather::Sandstorm] = [[], -12, 4, -2] + @weatherTypes[PBFieldWeather::Rain] = [[], nil, -1200 / Graphics.frame_rate, 4800 / Graphics.frame_rate, 0] + @weatherTypes[PBFieldWeather::HeavyRain] = [[], nil, -4800 / Graphics.frame_rate, 4800 / Graphics.frame_rate, 0] + @weatherTypes[PBFieldWeather::Storm] = [[], nil, -4800 / Graphics.frame_rate, 4800 / Graphics.frame_rate, 0] + @weatherTypes[PBFieldWeather::Snow] = [[], nil, -240 / Graphics.frame_rate, 240 / Graphics.frame_rate, 0] + @weatherTypes[PBFieldWeather::Blizzard] = [[], [], -960 / Graphics.frame_rate, 64 / Graphics.frame_rate, 0, + -1440 / Graphics.frame_rate, 720 / Graphics.frame_rate] + @weatherTypes[PBFieldWeather::Sandstorm] = [[], [], -1200 / Graphics.frame_rate, 640 / Graphics.frame_rate, 0, + -720 / Graphics.frame_rate, 360 / Graphics.frame_rate] @weatherTypes[PBFieldWeather::Sun] = nil @sprites = [] + @sprite_lifetimes = [] + @tiles = [] end def dispose - @sprites.each { |s| s.dispose } + @sprites.each { |sprite| sprite.dispose if sprite } + @tiles.each { |sprite| sprite.dispose if sprite } @viewport.dispose @weatherTypes.each do |weather| next if !weather weather[0].each { |bitmap| bitmap.dispose if bitmap } - end - end - - def ox=(ox) - return if @ox==ox - @ox = ox - @sprites.each { |s| s.ox = @ox } - end - - def oy=(oy) - return if @oy==oy - @oy = oy - @sprites.each { |s| s.oy = @oy } - end - - def prepareRainBitmap - rainColor = Color.new(255,255,255,255) - @rain_bitmap = Bitmap.new(32,128) - for i in 0...16 - @rain_bitmap.fill_rect(30-(i*2),i*8,2,8,rainColor) - end - @weatherTypes[PBFieldWeather::Rain][0][0] = @rain_bitmap - end - - def prepareStormBitmap - rainColor = Color.new(255,255,255,255) - @storm_bitmap = Bitmap.new(192,192) - for i in 0...96 - @storm_bitmap.fill_rect(190-(i*2),i*2,2,2,rainColor) - end - @weatherTypes[PBFieldWeather::HeavyRain][0][0] = @storm_bitmap - @weatherTypes[PBFieldWeather::Storm][0][0] = @storm_bitmap - end - - def prepareSnowBitmaps - return if @snowBitmap1 - bmWidth = 10 - bmHeight = 10 - @snowBitmap1 = Bitmap.new(bmWidth,bmHeight) - @snowBitmap2 = Bitmap.new(bmWidth,bmHeight) - @snowBitmap3 = Bitmap.new(bmWidth,bmHeight) - snowColor = Color.new(224, 232, 240) - # Small + shape - @snowBitmap1.fill_rect(4,2,2,2,snowColor) - @snowBitmap1.fill_rect(2,4,6,2,snowColor) - @snowBitmap1.fill_rect(4,6,2,2,snowColor) - # Fatter + shape - @snowBitmap2.fill_rect(2,0,4,2,snowColor) - @snowBitmap2.fill_rect(0,2,8,4,snowColor) - @snowBitmap2.fill_rect(2,6,4,2,snowColor) - # Diamond shape - @snowBitmap3.fill_rect(4,0,2,2,snowColor) - @snowBitmap3.fill_rect(2,2,6,2,snowColor) - @snowBitmap3.fill_rect(0,4,10,2,snowColor) - @snowBitmap3.fill_rect(2,6,6,2,snowColor) - @snowBitmap3.fill_rect(4,8,2,2,snowColor) - @weatherTypes[PBFieldWeather::Snow][0] = [@snowBitmap1,@snowBitmap2,@snowBitmap3] - end - - def prepareBlizzardBitmaps - return if @blizzardBitmap1 - bmWidth = 10; bmHeight = 10 - @blizzardBitmap1 = Bitmap.new(bmWidth,bmHeight) - @blizzardBitmap2 = Bitmap.new(bmWidth,bmHeight) - bmWidth = 200; bmHeight = 200 - @blizzardBitmap3 = Bitmap.new(bmWidth,bmHeight) - @blizzardBitmap4 = Bitmap.new(bmWidth,bmHeight) - snowColor = Color.new(224,232,240,255) - # Fatter + shape - @blizzardBitmap1.fill_rect(2,0,4,2,snowColor) - @blizzardBitmap1.fill_rect(0,2,8,4,snowColor) - @blizzardBitmap1.fill_rect(2,6,4,2,snowColor) - # Diamond shape - @blizzardBitmap2.fill_rect(4,0,2,2,snowColor) - @blizzardBitmap2.fill_rect(2,2,6,2,snowColor) - @blizzardBitmap2.fill_rect(0,4,10,2,snowColor) - @blizzardBitmap2.fill_rect(2,6,6,2,snowColor) - @blizzardBitmap2.fill_rect(4,8,2,2,snowColor) - 540.times do - @blizzardBitmap3.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor) - @blizzardBitmap4.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor) - end - @weatherTypes[PBFieldWeather::Blizzard][0][0] = @blizzardBitmap1 - @weatherTypes[PBFieldWeather::Blizzard][0][1] = @blizzardBitmap2 - @weatherTypes[PBFieldWeather::Blizzard][0][2] = @blizzardBitmap3 # Tripled to make them 3x as common - @weatherTypes[PBFieldWeather::Blizzard][0][3] = @blizzardBitmap3 - @weatherTypes[PBFieldWeather::Blizzard][0][4] = @blizzardBitmap3 - @weatherTypes[PBFieldWeather::Blizzard][0][5] = @blizzardBitmap4 # Tripled to make them 3x as common - @weatherTypes[PBFieldWeather::Blizzard][0][6] = @blizzardBitmap4 - @weatherTypes[PBFieldWeather::Blizzard][0][7] = @blizzardBitmap4 - end - - def prepareSandstormBitmaps - return if @sandstormBitmap1 - sandstormColors = [ - Color.new(31*8, 28*8, 17*8), - Color.new(23*8, 16*8, 9*8), - Color.new(29*8, 24*8, 15*8), - Color.new(26*8, 20*8, 12*8), - Color.new(20*8, 13*8, 6*8), - Color.new(31*8, 30*8, 20*8), - Color.new(27*8, 25*8, 20*8) - ] - bmWidth = 200 - bmHeight = 200 - @sandstormBitmap1 = Bitmap.new(bmWidth,bmHeight) - @sandstormBitmap2 = Bitmap.new(bmWidth,bmHeight) - 540.times do - @sandstormBitmap1.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2, - sandstormColors[rand(sandstormColors.length)]) - @sandstormBitmap2.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2, - sandstormColors[rand(sandstormColors.length)]) - end - @weatherTypes[PBFieldWeather::Sandstorm][0] = [@sandstormBitmap1,@sandstormBitmap2] - end - - def ensureSprites - return if @sprites.length>=40 - for i in 0...40 - if !@sprites[i] - sprite = Sprite.new(@origViewport) - sprite.z = 1000 - sprite.ox = @ox - sprite.oy = @oy - sprite.opacity = 0 - @sprites.push(sprite) - end - @sprites[i].visible = (i<=@max) - end - end - - def max=(max) - return if @max==max - @max = [[max,0].max,40].min - if @max==0 - @sprites.each { |s| s.dispose } - @sprites.clear - else - @sprites.each_with_index { |s,i| s.visible = (i<=@max) if s } + weather[1].each { |bitmap| bitmap.dispose if bitmap } if weather[1] end end def type=(type) - return if @type==type + return if @type == type @type = type case @type when PBFieldWeather::None - @sprites.each { |s| s.dispose } + @sprites.each { |sprite| sprite.dispose if sprite } @sprites.clear + @tiles.each { |sprite| sprite.dispose if sprite } + @tiles.clear + @tiles_wide = @tiles_tall = 0 return when PBFieldWeather::Rain then prepareRainBitmap when PBFieldWeather::HeavyRain, PBFieldWeather::Storm then prepareStormBitmap @@ -190,62 +68,253 @@ module RPG when PBFieldWeather::Blizzard then prepareBlizzardBitmaps when PBFieldWeather::Sandstorm then prepareSandstormBitmaps end - weatherBitmaps = (@type==PBFieldWeather::None || @type==PBFieldWeather::Sun) ? nil : @weatherTypes[@type][0] + if @weatherTypes[@type] && @weatherTypes[@type][1] && @weatherTypes[@type][1].length > 0 + w = @weatherTypes[@type][1][0].width + h = @weatherTypes[@type][1][0].height + @tiles_wide = (Graphics.width.to_f / w).ceil + 1 + @tiles_tall = (Graphics.height.to_f / h).ceil + 1 + end ensureSprites - @sprites.each_with_index do |s,i| - next if !s - s.mirror = false - s.mirror = (rand(2)==0) if @type==PBFieldWeather::Blizzard || @type==PBFieldWeather::Sandstorm - s.bitmap = (weatherBitmaps) ? weatherBitmaps[i%weatherBitmaps.length]: nil + @sprites.each_with_index { |sprite, i| set_sprite_bitmap(sprite, i) } + @tiles.each_with_index { |sprite, i| set_tile_bitmap(sprite, i) } + end + + def set_sprite_bitmap(sprite, index) + return if !sprite + weatherBitmaps = (@weatherTypes[@type]) ? @weatherTypes[@type][0] : nil + if !weatherBitmaps + sprite.bitmap = nil + return + end + case @type + when PBFieldWeather::Rain, PBFieldWeather::HeavyRain, PBFieldWeather::Storm + last_index = weatherBitmaps.length - 1 # Last sprite is splash + if index % 2 == 0 + sprite.bitmap = weatherBitmaps[index % last_index] + else + sprite.bitmap = weatherBitmaps[last_index] + end + else + sprite.bitmap = weatherBitmaps[index % weatherBitmaps.length] + end + end + + def set_tile_bitmap(sprite, index) + return if !sprite + weatherBitmaps = (@weatherTypes[@type]) ? @weatherTypes[@type][1] : nil + if !weatherBitmaps || weatherBitmaps.length == 0 + sprite.bitmap = nil + return + end + sprite.bitmap = weatherBitmaps[index % weatherBitmaps.length] + reset_tile_position(sprite, index) + end + + def max=(value) + return if @max == value + @max = value.clamp(0, MAX_SPRITES) + if @max == 0 + @sprites.each { |sprite| sprite.dispose if sprite } + @sprites.clear + @tiles.each { |sprite| sprite.dispose if sprite } + @tiles.clear + else + @sprites.each_with_index { |sprite, i| sprite.visible = (i <= @max) if sprite } + end + end + + def ox=(value) + return if value == @ox + @ox = value + @sprites.each { |sprite| sprite.ox = @ox if sprite } + @tiles.each { |sprite| sprite.ox = @ox if sprite } + end + + def oy=(value) + return if value == @oy + @oy = value + @sprites.each { |sprite| sprite.oy = @oy if sprite } + @tiles.each { |sprite| sprite.oy = @oy if sprite } + end + + def prepareRainBitmap + rain1 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_1") + rain2 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_2") + rain3 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_3") + rain4 = RPG::Cache.load_bitmap("Graphics/Weather/", "rain_4") # Splash + @weatherTypes[PBFieldWeather::Rain][0] = [rain1, rain2, rain3, rain4] + end + + def prepareStormBitmap + storm1 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_1") + storm2 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_2") + storm3 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_3") + storm4 = RPG::Cache.load_bitmap("Graphics/Weather/", "storm_4") # Splash + @weatherTypes[PBFieldWeather::HeavyRain][0] = [storm1, storm2, storm3, storm4] + @weatherTypes[PBFieldWeather::Storm][0] = [storm1, storm2, storm3, storm4] + end + + def prepareSnowBitmaps + hail1 = RPG::Cache.load_bitmap("Graphics/Weather/", "hail_1") + hail2 = RPG::Cache.load_bitmap("Graphics/Weather/", "hail_2") + hail3 = RPG::Cache.load_bitmap("Graphics/Weather/", "hail_3") + @weatherTypes[PBFieldWeather::Snow][0] = [hail1, hail2, hail3] + end + + def prepareBlizzardBitmaps + blizzard1 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_1") + blizzard2 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_2") + blizzard3 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_3") + blizzard4 = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_4") + @weatherTypes[PBFieldWeather::Blizzard][0] = [blizzard1, blizzard2, blizzard3, blizzard4] + blizzard_tile = RPG::Cache.load_bitmap("Graphics/Weather/", "blizzard_tile") + @weatherTypes[PBFieldWeather::Blizzard][1] = [blizzard_tile] + end + + def prepareSandstormBitmaps + sandstorm1 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_1") + sandstorm2 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_2") + sandstorm3 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_3") + sandstorm4 = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_4") + @weatherTypes[PBFieldWeather::Sandstorm][0] = [sandstorm1, sandstorm2, sandstorm3, sandstorm4] + sandstorm_tile = RPG::Cache.load_bitmap("Graphics/Weather/", "sandstorm_tile") + @weatherTypes[PBFieldWeather::Sandstorm][1] = [sandstorm_tile] + end + + def ensureSprites + if @sprites.length < MAX_SPRITES + for i in 0...MAX_SPRITES + if !@sprites[i] + sprite = Sprite.new(@origViewport) + sprite.z = 1000 + sprite.ox = @ox + sprite.oy = @oy + sprite.opacity = 0 + @sprites[i] = sprite + end + @sprites[i].visible = (i <= @max) + @sprite_lifetimes[i] = 0 + end + end + if @tiles.length < @tiles_wide * @tiles_tall + for i in 0...(@tiles_wide * @tiles_tall) + if !@tiles[i] + sprite = Sprite.new(@origViewport) + sprite.z = 1000 + sprite.ox = @ox + sprite.oy = @oy + sprite.opacity = 0 + @tiles[i] = sprite + end + @tiles[i].visible = true + end + end + end + + def reset_sprite_position(sprite, index) + if [PBFieldWeather::Rain, PBFieldWeather::HeavyRain, PBFieldWeather::Storm].include?(@type) && index % 2 != 0 # Splash + sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2) + sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + sprite.bitmap.height * 2) + @sprite_lifetimes[index] = Graphics.frame_rate * (30 + rand(20)) / 100 + else + gradient = @weatherTypes[@type][2].to_f / @weatherTypes[@type][3] + sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2 - gradient * Graphics.height) + sprite.y = @oy - sprite.bitmap.height - rand(Graphics.height) + @sprite_lifetimes[index] = (@oy - sprite.y + rand(Graphics.height * 8 / 5)) / @weatherTypes[@type][3] + end + sprite.opacity = 255 + end + + def update_sprite_position(sprite, index) + return if !sprite + if @sprite_lifetimes[index] > 0 + @sprite_lifetimes[index] -= 1 + if @sprite_lifetimes[index] == 0 + reset_sprite_position(sprite, index) + return + end + end + if [PBFieldWeather::Rain, PBFieldWeather::HeavyRain, PBFieldWeather::Storm].include?(@type) && index % 2 != 0 # Splash + sprite.visible = (@sprite_lifetimes[index] < Graphics.frame_rate * 2 / 10) + else + sprite.x += @weatherTypes[@type][2] + sprite.y += @weatherTypes[@type][3] + if @type == PBFieldWeather::Snow || @type == PBFieldWeather::Blizzard + sprite.x -= (4 * (sprite.y - @oy)) / Graphics.height + sprite.x -= [2, 1, 0, -1][rand(4)] + sprite.y += index % 6 + end + sprite.opacity += @weatherTypes[@type][4] + end + x = sprite.x - @ox + y = sprite.y - @oy + # Check if sprite is off-screen; if so, reset it + if sprite.opacity < 64 || x < -sprite.bitmap.width || y > Graphics.height + reset_sprite_position(sprite, index) + end + end + + def reset_tile_position(sprite, index) + sprite.x = @ox + (index % @tiles_wide) * sprite.bitmap.width + sprite.y = @oy + (index / @tiles_wide) * sprite.bitmap.height + end + + def update_tile_position(sprite, index) + return if !sprite || !sprite.bitmap + if @tiles_wide > 0 && @tiles_tall > 0 + sprite.x += @weatherTypes[@type][5] + sprite.y += @weatherTypes[@type][6] + sprite.x += @tiles_wide * sprite.bitmap.width if sprite.x - @ox + sprite.bitmap.width < 0 + sprite.y -= @tiles_tall * sprite.bitmap.height if sprite.y - @oy > Graphics.height + sprite.visible = true + sprite.opacity = 255 + else + sprite.visible = false + end + end + + # Set tone of viewport (general screen brightening/darkening) + def update_screen_tone + # @max is (power+1)*MAX_SPRITES/10, where power is between 1 and 9 + case @type + when PBFieldWeather::None + @viewport.tone.set(0, 0, 0, 0) + when PBFieldWeather::Rain + @viewport.tone.set(-@max * 3 / 4, -@max * 3 / 4, -@max * 3 / 4, 10) + when PBFieldWeather::HeavyRain + @viewport.tone.set(-@max * 6 / 4, -@max * 6 / 4, -@max * 6 / 4, 20) + when PBFieldWeather::Storm + @viewport.tone.set(-@max * 6 / 4, -@max * 6 / 4, -@max * 6 / 4, 20) + when PBFieldWeather::Snow + @viewport.tone.set( @max / 2, @max / 2, @max / 2, 0) + when PBFieldWeather::Blizzard + @viewport.tone.set( @max * 3 / 4, @max * 3 / 4, max * 3 / 4, 0) + when PBFieldWeather::Sandstorm + @viewport.tone.set( @max / 2, 0, -@max / 2, 0) + when PBFieldWeather::Sun + @sun = @max if @sun != @max && @sun != -@max + @sun = -@sun if @sunValue > @max || @sunValue < 0 + @sunValue = @sunValue + @sun / 32 + @viewport.tone.set(@sunValue + 63, @sunValue + 63, @sunValue / 2 + 31, 0) end end def update - # @max is (power+1)*4, where power is between 1 and 9 - # Set tone of viewport (general screen brightening/darkening) - case @type - when PBFieldWeather::None then @viewport.tone.set(0, 0, 0, 0) - when PBFieldWeather::Rain then @viewport.tone.set(-@max * 3 / 4, -@max * 3 / 4, -@max * 3 / 4, 10) - when PBFieldWeather::HeavyRain then @viewport.tone.set(-@max * 6 / 4, -@max * 6 / 4, -@max * 6 / 4, 20) - when PBFieldWeather::Storm then @viewport.tone.set(-@max * 6 / 4, -@max * 6 / 4, -@max * 6 / 4, 20) - when PBFieldWeather::Snow then @viewport.tone.set( @max / 2, @max / 2, @max / 2, 0) - when PBFieldWeather::Blizzard then @viewport.tone.set( @max * 3 / 4, @max * 3 / 4, max * 3 / 4, 0) - when PBFieldWeather::Sandstorm then @viewport.tone.set( @max / 2, 0, -@max / 2, 0) - when PBFieldWeather::Sun - @sun = @max if @sun!=@max && @sun!=-@max - @sun = -@sun if @sunValue>@max || @sunValue<0 - @sunValue = @sunValue+@sun/32 - @viewport.tone.set(@sunValue+63,@sunValue+63,@sunValue/2+31,0) - end + # @max is (power+1)*MAX_SPRITES/10, where power is between 1 and 9 + update_screen_tone # Storm flashes - if @type==PBFieldWeather::Storm + if @type == PBFieldWeather::Storm rnd = rand(300) - @viewport.flash(Color.new(255,255,255,230),rnd*20) if rnd<4 + @viewport.flash(Color.new(255, 255, 255, 230), rnd * 20) if rnd < 4 end @viewport.update - return if @type==PBFieldWeather::None || @type==PBFieldWeather::Sun # Update weather particles (raindrops, snowflakes, etc.) - ensureSprites - for i in 1..@max - sprite = @sprites[i] - break if sprite==nil - sprite.x += @weatherTypes[@type][1] - sprite.x += [2,0,0,-2][rand(4)] if @type==PBFieldWeather::Snow || @type==PBFieldWeather::Blizzard - sprite.y += @weatherTypes[@type][2] - sprite.opacity += @weatherTypes[@type][3] - # Check if sprite is off-screen; if so, reset it - x = sprite.x-@ox - y = sprite.y-@oy - nomWidth = Graphics.width - nomHeight = Graphics.height - if sprite.opacity<64 || x<-50 || x>nomWidth+128 || y<-300 || y>nomHeight+20 - sprite.x = rand(nomWidth+150)-50+@ox - sprite.y = rand(nomHeight+150)-200+@oy - sprite.opacity = 255 - sprite.mirror = false - sprite.mirror = (rand(2)==0) if @type==PBFieldWeather::Blizzard || @type==PBFieldWeather::Sandstorm + if @weatherTypes[@type] + ensureSprites + for i in 0...@max + update_sprite_position(@sprites[i], i) end - pbDayNightTint(sprite) + @tiles.each_with_index { |sprite, i| update_tile_position(sprite, i) } end end end