Fixed overworld weather moving relative to the screen rather than the map

This commit is contained in:
Maruno17
2021-09-20 23:25:12 +01:00
parent 4edd06208a
commit 694e567f3d

View File

@@ -294,6 +294,10 @@ module RPG
sprite.x += [2, 1, 0, -1][rand(4)] * dist_x / 8 # Random movement sprite.x += [2, 1, 0, -1][rand(4)] * dist_x / 8 # Random movement
sprite.y += [2, 1, 1, 0, 0, -1][index % 6] * dist_y / 10 # Variety sprite.y += [2, 1, 1, 0, 0, -1][index % 6] * dist_y / 10 # Variety
end end
sprite.x -= Graphics.width if sprite.x - @ox > Graphics.width
sprite.x += Graphics.width if sprite.x - @ox < -sprite.width
sprite.y -= Graphics.height if sprite.y - @oy > Graphics.height
sprite.y += Graphics.height if sprite.y - @oy < -sprite.height
sprite.opacity += @weatherTypes[weather_type][0].particle_delta_opacity * delta_t sprite.opacity += @weatherTypes[weather_type][0].particle_delta_opacity * delta_t
x = sprite.x - @ox x = sprite.x - @ox
y = sprite.y - @oy y = sprite.y - @oy
@@ -312,18 +316,24 @@ module RPG
end end
@tile_x += @weatherTypes[weather_type][0].tile_delta_x * delta_t @tile_x += @weatherTypes[weather_type][0].tile_delta_x * delta_t
@tile_y += @weatherTypes[weather_type][0].tile_delta_y * delta_t @tile_y += @weatherTypes[weather_type][0].tile_delta_y * delta_t
if @tile_x < -@tiles_wide * @weatherTypes[weather_type][2][0].width while @tile_x < @ox - @weatherTypes[weather_type][2][0].width
@tile_x += @tiles_wide * @weatherTypes[weather_type][2][0].width @tile_x += @weatherTypes[weather_type][2][0].width
end end
if @tile_y > @tiles_tall * @weatherTypes[weather_type][2][0].height while @tile_x > @ox
@tile_y -= @tiles_tall * @weatherTypes[weather_type][2][0].height @tile_x -= @weatherTypes[weather_type][2][0].width
end
while @tile_y < @oy - @weatherTypes[weather_type][2][0].height
@tile_y += @weatherTypes[weather_type][2][0].height
end
while @tile_y > @oy
@tile_y -= @weatherTypes[weather_type][2][0].height
end end
end end
def update_tile_position(sprite, index) def update_tile_position(sprite, index)
return if !sprite || !sprite.bitmap || !sprite.visible return if !sprite || !sprite.bitmap || !sprite.visible
sprite.x = (@ox + @tile_x + (index % @tiles_wide) * sprite.bitmap.width).round sprite.x = @tile_x.round + (index % @tiles_wide) * sprite.bitmap.width
sprite.y = (@oy + @tile_y + (index / @tiles_wide) * sprite.bitmap.height).round sprite.y = @tile_y.round + (index / @tiles_wide) * sprite.bitmap.height
sprite.x += @tiles_wide * sprite.bitmap.width if sprite.x - @ox < -sprite.bitmap.width sprite.x += @tiles_wide * sprite.bitmap.width if sprite.x - @ox < -sprite.bitmap.width
sprite.y -= @tiles_tall * sprite.bitmap.height if sprite.y - @oy > Graphics.height sprite.y -= @tiles_tall * sprite.bitmap.height if sprite.y - @oy > Graphics.height
sprite.visible = true sprite.visible = true