Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Multiple Fogs request [XP]

Hey guys,

I'm not sure whether this is a simple request or not, but does anyone have any spare time to make a multiple fog script?
aliasing, if thats possible :)

i need one because i'm making sandstorms and foggy forests and such, and i need a way to show multiple fogs at once. i'm sure it would help a lot of people out :) (for custom lighting scenes as well)
i apologise if i ask too much :)

if you do have time on your hands, could it possibly set up in a hash or something like:
FOGS[map_id] = [[name,move_x,move_y,opacity],[name,move_x,move_y,opacity]]
whatever works :)

that would be amazing!
 

Atoa

Member

try this:
Code:
#================================================================

# Cross Multifog system (2.2)

# por Alex Crosslight

# [url=http://ateliercross.6te.net]http://ateliercross.6te.net[/url]

#################################################################

# Histórico:

#################################################################

#

# Versão 1.0

#

# > Atribui uma fog simultânea ao mapa

#

# Versão 1.5

#

# > A fog é salva junto com o game_system

# > Você pode chamar mais de uma fog simultânea.

#

# Versão 2.0

#

# > Bugs quanto a criação de fogs e mudança de tal corrigida.

# > Adicionado os métodos de remoção de fog e zeramento de fogs.

#

# Versão 2.1

#

# > Bugs no blend foram corrigidos por Kress.

#

# Versão 2.2

#

# > Bugs em várias funções foram corrigidos por Kress.

# > Script totalmente funcional, com uma função nova: Hue

#

#================================================================

# O script permite atribuir mais de uma fog simultânea

# além da definida no mapa.

#================================================================

# >> Use o comando chamar script e digite:

# > create_fog(name,ox,oy,opacity,z,blend,magn,hue)

#

# name = nome do fog entre "aspas"

# ox = velocidade na horizontal

# oy = velocidade na vertical

# opacity = opacidade

# z = Prioridade da fog, também servirá de ID para ela

# blend = Sinteticidade da fog (0 - normal, 1 - inverter, 2 - multiplicar)

# magn = magnitude da fog

# hue  = tonalidade da nevoa (novo)

#

# >> Para apagar uma fog, use o comando:

#

# > remove_fog(z)

#

# z é a ID da fog, ou a prioridade dela configurada anteriormente.

#

# >> Para deletar todas as fogs, use o comando:

#

# > clear_multifog

#

#================================================================

# INICIO DO SCRIPT

#================================================================

 

#==============================================================================

# Game_System

#==============================================================================

 

class Game_System

 

 attr_accessor :multifog

 attr_accessor :eraser_multifog

 attr_accessor :coor_origin

 

 #--------------------------------------------------------------------------

 # Inicialização dos Objetos

 #--------------------------------------------------------------------------

 

 alias multifog_initialize initialize

 def initialize

 multifog_initialize

 @multifog = {}

 @eraser_multifog = "none"

 @coor_origin = {}

 end

end     

 

#==============================================================================

# Interpreter

#==============================================================================

 

class Interpreter

 

 def create_fog(name,ox,oy,opacity,z,blend,magn,hue)

 $game_system.multifog[z] = [name,ox,oy,opacity,z,blend,magn,hue]

 end

 

 def remove_fog(z)

 unless $game_system.multifog[z] == nil

 $game_system.multifog.delete_if{|key, value| key == z }

 $game_system.eraser_multifog = z

 end

 end

 

 def clear_multifog

 unless $game_system.multifog.keys.size < 1

 $game_system.eraser_multifog = "all"

 end

 end

end

 

#==============================================================================

# Spriteset_Map

#==============================================================================

 

class Spriteset_Map

 

 #--------------------------------------------------------------------------

 # Inicialização dos Objetos

 #--------------------------------------------------------------------------

 

 alias multifog_initialize initialize

 def initialize

 multifog_initialize

 @neo_multifog = {} if @neo_multifog == nil

 @neo_multifog2 = {} if @neo_multifog2 == nil

 end

 

 #--------------------------------------------------------------------------

 # Apagar objetos

 #--------------------------------------------------------------------------

 

 alias multifog_dispose dispose

 def dispose

 multifog_dispose

 dispose_one_new_p

 end

 

 #--------------------------------------------------------------------------

 # Criar novos objetos

 #--------------------------------------------------------------------------

 

 def create_new_plane

 @neo_multifog2 = {} if @neo_multifog2 == nil

 for n in $game_system.multifog.keys

 unless @neo_multifog2[n] == nil

 @neo_multifog2[n].dispose

 end

 @neo_multifog2[n] = Plane.new(@viewport1)

 @neo_multifog2[n].bitmap = RPG::Cache.fog($game_system.multifog[n][0],

 $game_system.multifog[n][7])

 

 @neo_multifog2[n].opacity = $game_system.multifog[n][3]

 @neo_multifog2[n].z = (3000 + (n + 1))

 @neo_multifog2[n].blend_type = $game_system.multifog[n][5]

 @neo_multifog2[n].zoom_x = $game_system.multifog[n][6].to_f / 100.00

 @neo_multifog2[n].zoom_y = $game_system.multifog[n][6].to_f / 100.00

 end

 end

 

 #--------------------------------------------------------------------------

 # Apagar novos objetos

 #-------------------------------------------------------------------------- 

 

 def dispose_new_plane

 if $game_system.multifog.keys.size != 0

 for n in $game_system.multifog.keys

 @neo_multifog2[n].dispose

 end

 $game_system.multifog = {}

 end

 end

 

 #--------------------------------------------------------------------------

 # Apagar novos objetos

 #-------------------------------------------------------------------------- 

 

 def dispose_one_new_p

 if $game_system.multifog.keys.size != 0

 for n in $game_system.multifog.keys

 @neo_multifog2[n].dispose

 end

 end

 end

 

 #--------------------------------------------------------------------------

 # Atualização do Frame

 #--------------------------------------------------------------------------

 

 alias multifog_n_update update

 def update

 multifog_n_update

 if $game_system.eraser_multifog != "none"

 if $game_system.eraser_multifog.is_a?(Integer)

 if @neo_multifog2.keys.include?($game_system.eraser_multifog)

 @neo_multifog2[$game_system.eraser_multifog].dispose

 $game_system.eraser_multifog = "none"

 end

 elsif $game_system.eraser_multifog == "all"

 dispose_new_plane

 $game_system.eraser_multifog = "none"

 end

 end

 

 if $game_system.multifog.values != @neo_multifog

 @neo_multifog = $game_system.multifog.values

 create_new_plane

 end

 for n in $game_system.multifog.keys

 if $game_system.coor_origin[n] == nil

 $game_system.coor_origin[n] = [0]

 $game_system.coor_origin[n].push(0)

 end

 end

 for n in $game_system.multifog.keys

 $game_system.coor_origin[n][0] -= $game_system.multifog[n][1] / 8.0

 $game_system.coor_origin[n][1] -= $game_system.multifog[n][2] / 8.0

 end

 for n in $game_system.multifog.keys

 unless $game_system.multifog[n][1] != 0

 @neo_multifog2[n].ox = $game_map.display_x / 4 +

 $game_system.multifog[n][1]

 else

 @neo_multifog2[n].ox -= $game_system.multifog[n][1]

 end

 unless $game_system.multifog[n][2] != 0

 @neo_multifog2[n].oy = $game_map.display_y / 4 +

 $game_system.multifog[n][2]

 else

 @neo_multifog2[n].oy -= $game_system.multifog[n][2]

 end

 end

 end

end

 

#================================================================

# FIM DO SCRIPT =*

#================================================================


translate the instructions with google translator
 
Thanks Atoa - I went onto that website earlier, but it didn't work from there.
One thing - what would i throw into Scene_Map.transfer_player to make it automatically dispose all fogs?
it doesn't automatically dispose, and its a pain to have to make extra unnecessary events on every map.

Edit: Nevermind, its cool :)

Edit: Okay, there's something wrong with this script. When I move up and down, the fog stays in sync with the map (as per usual).
But when I move side to side, it follows the player, rather than the map (like a picture) and it looks horrible :\
 
I need help with this - i've looked through the script, but I can't identify the error :\

EDIT: I've changed the script slightly -
Code:
#================================================================

# Cross Multifog system (2.2)

# por Alex Crosslight

# [url=http://ateliercross.6te.net]http://ateliercross.6te.net[/url]

#################################################################

# Histórico:

#################################################################

#

# Versão 1.0

#

# > Atribui uma fog simultânea ao mapa

#

# Versão 1.5

#

# > A fog é salva junto com o game_system

# > Você pode chamar mais de uma fog simultânea.

#

# Versão 2.0

#

# > Bugs quanto a criação de fogs e mudança de tal corrigida.

# > Adicionado os métodos de remoção de fog e zeramento de fogs.

#

# Versão 2.1

#

# > Bugs no blend foram corrigidos por Kress.

#

# Versão 2.2

#

# > Bugs em várias funções foram corrigidos por Kress.

# > Script totalmente funcional, com uma função nova: Hue

#

#================================================================

# O script permite atribuir mais de uma fog simultânea

# além da definida no mapa.

#================================================================

# >> Use o comando chamar script e digite:

# > create_fog(name,ox,oy,opacity,z,blend,magn,hue)

#

# name = nome do fog entre "aspas"

# ox = velocidade na horizontal

# oy = velocidade na vertical

# opacity = opacidade

# z = Prioridade da fog, também servirá de ID para ela

# blend = Sinteticidade da fog (0 - normal, 1 - inverter, 2 - multiplicar)

# magn = magnitude da fog

# hue  = tonalidade da nevoa (novo)

#

# >> Para apagar uma fog, use o comando:

#

# > remove_fog(z)

#

# z é a ID da fog, ou a prioridade dela configurada anteriormente.

#

# >> Para deletar todas as fogs, use o comando:

#

# > clear_multifog

#

#================================================================

# INICIO DO SCRIPT

#================================================================

 

#==============================================================================

# Game_System

#==============================================================================

 

class Game_System

 

 attr_accessor :multifog

 attr_accessor :eraser_multifog

 attr_accessor :coor_origin

 

 #--------------------------------------------------------------------------

 # Inicialização dos Objetos

 #--------------------------------------------------------------------------

 

 alias multifog_initialize initialize

 def initialize

 multifog_initialize

 @multifog = {}

 @eraser_multifog = "none"

 @coor_origin = {}

 end

end    

 

#==============================================================================

# Interpreter

#==============================================================================

 

class Interpreter

 

 def create_fog(name,ox,oy,opacity,z,blend,magn,hue)

 $game_system.multifog[z] = [name,ox,oy,opacity,z,blend,magn,hue]

 end

 

 def remove_fog(z)

 unless $game_system.multifog[z] == nil

 $game_system.multifog.delete_if{|key, value| key == z }

 $game_system.eraser_multifog = z

 end

 end

 

 def clear_multifog

 unless $game_system.multifog.keys.size < 1

 $game_system.eraser_multifog = "all"

 end

 end

end

 

#==============================================================================

# Spriteset_Map

#==============================================================================

 

class Spriteset_Map

 

 #--------------------------------------------------------------------------

 # Inicialização dos Objetos

 #--------------------------------------------------------------------------

 

 alias multifog_initialize initialize

 def initialize

 multifog_initialize

 @neo_multifog = {} if @neo_multifog == nil

 @neo_multifog2 = {} if @neo_multifog2 == nil

 end

 

 #--------------------------------------------------------------------------

 # Apagar objetos

 #--------------------------------------------------------------------------

 

 alias multifog_dispose dispose

 def dispose

 multifog_dispose

 dispose_one_new_p

 end

 

 #--------------------------------------------------------------------------

 # Criar novos objetos

 #--------------------------------------------------------------------------

 

 def create_new_plane

 @neo_multifog2 = {} if @neo_multifog2 == nil

 for n in $game_system.multifog.keys

 unless @neo_multifog2[n] == nil

 @neo_multifog2[n].dispose

 end

 @neo_multifog2[n] = Plane.new(@viewport1)

 @neo_multifog2[n].bitmap = RPG::Cache.fog($game_system.multifog[n][0],

 $game_system.multifog[n][7])

 

 @neo_multifog2[n].opacity = $game_system.multifog[n][3]

 @neo_multifog2[n].z = (3000 + (n + 1))

 @neo_multifog2[n].blend_type = $game_system.multifog[n][5]

 @neo_multifog2[n].zoom_x = $game_system.multifog[n][6].to_f / 100.00

 @neo_multifog2[n].zoom_y = $game_system.multifog[n][6].to_f / 100.00

 end

 end

 

 #--------------------------------------------------------------------------

 # Apagar novos objetos

 #--------------------------------------------------------------------------

 

 def dispose_new_plane

 if $game_system.multifog.keys.size != 0

 for n in $game_system.multifog.keys

 @neo_multifog2[n].dispose

 end

 $game_system.multifog = {}

 end

 end

 

 #--------------------------------------------------------------------------

 # Apagar novos objetos

 #--------------------------------------------------------------------------

 

 def dispose_one_new_p

 if $game_system.multifog.keys.size != 0

 for n in $game_system.multifog.keys

 @neo_multifog2[n].dispose unless @neo_multifog2[n] == nil or @neo_multifog2[n].disposed?

 end

 end

 end

 

 #--------------------------------------------------------------------------

 # Atualização do Frame

 #--------------------------------------------------------------------------

 

 alias multifog_n_update update

 def update

 multifog_n_update

 if $game_system.eraser_multifog != "none"

 if $game_system.eraser_multifog.is_a?(Integer)

 if @neo_multifog2.keys.include?($game_system.eraser_multifog)

 @neo_multifog2[$game_system.eraser_multifog].dispose

 $game_system.eraser_multifog = "none"

 end

 elsif $game_system.eraser_multifog == "all"

 dispose_new_plane

 $game_system.eraser_multifog = "none"

 end

 end

 

 if $game_system.multifog.values != @neo_multifog

 @neo_multifog = $game_system.multifog.values

 create_new_plane

 end

 for n in $game_system.multifog.keys

 if $game_system.coor_origin[n] == nil

 $game_system.coor_origin[n] = [0,0]

 #$game_system.coor_origin[n].push(0)

 end

 end

 for n in $game_system.multifog.keys

 $game_system.coor_origin[n][0] -= $game_system.multifog[n][1] / 8.0

 $game_system.coor_origin[n][1] -= $game_system.multifog[n][2] / 8.0

 end

 for n in $game_system.multifog.keys

 unless $game_system.multifog[n][1] == 0

 @neo_multifog2[n].ox = $game_map.display_x / 4 +

 $game_system.multifog[n][1]

 else

 @neo_multifog2[n].ox -= $game_system.multifog[n][1]

 end

 unless $game_system.multifog[n][2] != 0

 @neo_multifog2[n].oy = $game_map.display_y / 4 +

 $game_system.multifog[n][2]

 else

 @neo_multifog2[n].oy -= $game_system.multifog[n][2]

 end

 end

 end

end

 

#================================================================

# FIM DO SCRIPT =*

#================================================================

I changed the != to == for the x axis, (line 217) now it stays in sync with the map. It doesn't move however :(
 
Just incase those reading are interested, this is the fixed one:

Code:
#================================================================

# Cross Multifog system (2.2)

# por Alex Crosslight

# [url=http://ateliercross.6te.net]http://ateliercross.6te.net[/url]

#################################################################

# Histórico:

#################################################################

#

# Versão 1.0

#

# > Atribui uma fog simultânea ao mapa

#

# Versão 1.5

#

# > A fog é salva junto com o game_system

# > Você pode chamar mais de uma fog simultânea.

#

# Versão 2.0

#

# > Bugs quanto a criação de fogs e mudança de tal corrigida.

# > Adicionado os métodos de remoção de fog e zeramento de fogs.

#

# Versão 2.1

#

# > Bugs no blend foram corrigidos por Kress.

#

# Versão 2.2

#

# > Bugs em várias funções foram corrigidos por Kress.

# > Script totalmente funcional, com uma função nova: Hue

#

#================================================================

# O script permite atribuir mais de uma fog simultânea

# além da definida no mapa.

#================================================================

# >> Use o comando chamar script e digite:

# > create_fog(name,ox,oy,opacity,z,blend,magn,hue)

#

# name = nome do fog entre "aspas"

# ox = velocidade na horizontal

# oy = velocidade na vertical

# opacity = opacidade

# z = Prioridade da fog, também servirá de ID para ela

# blend = Sinteticidade da fog (0 - normal, 1 - inverter, 2 - multiplicar)

# magn = magnitude da fog

# hue  = tonalidade da nevoa (novo)

#

# >> Para apagar uma fog, use o comando:

#

# > remove_fog(z)

#

# z é a ID da fog, ou a prioridade dela configurada anteriormente.

#

# >> Para deletar todas as fogs, use o comando:

#

# > clear_multifog

#

#================================================================

# INICIO DO SCRIPT

#================================================================

 

#==============================================================================

# Game_System

#==============================================================================

 

class Game_System

 

 attr_accessor :multifog

 attr_accessor :eraser_multifog

 attr_accessor :coor_origin

 

 #--------------------------------------------------------------------------

 # Inicialização dos Objetos

 #--------------------------------------------------------------------------

 

 alias multifog_initialize initialize

 def initialize

 multifog_initialize

 @multifog = {}

 @eraser_multifog = "none"

 @coor_origin = {}

 end

end    

 

#==============================================================================

# Interpreter

#==============================================================================

 

class Interpreter

 

 def create_fog(name,ox,oy,opacity,z,blend,magn,hue)

 $game_system.multifog[z] = [name,ox,oy,opacity,z,blend,magn,hue]

 end

 

 def remove_fog(z)

 unless $game_system.multifog[z] == nil

 $game_system.multifog.delete_if{|key, value| key == z }

 $game_system.eraser_multifog = z

 end

 end

 

 def clear_multifog

 unless $game_system.multifog.keys.size < 1

 $game_system.eraser_multifog = "all"

 end

 end

end

 

#==============================================================================

# Spriteset_Map

#==============================================================================

 

class Spriteset_Map

 

 #--------------------------------------------------------------------------

 # Inicialização dos Objetos

 #--------------------------------------------------------------------------

 

 alias multifog_initialize initialize

 def initialize

 multifog_initialize

 @neo_multifog = {} if @neo_multifog == nil

 @neo_multifog2 = {} if @neo_multifog2 == nil

 end

 

 #--------------------------------------------------------------------------

 # Apagar objetos

 #--------------------------------------------------------------------------

 

 alias multifog_dispose dispose

 def dispose

 multifog_dispose

 dispose_one_new_p

 end

 

 #--------------------------------------------------------------------------

 # Criar novos objetos

 #--------------------------------------------------------------------------

 

 def create_new_plane

 @neo_multifog2 = {} if @neo_multifog2 == nil

 for n in $game_system.multifog.keys

 unless @neo_multifog2[n] == nil

 @neo_multifog2[n].dispose

 end

 @neo_multifog2[n] = Plane.new(@viewport1)

 @neo_multifog2[n].bitmap = RPG::Cache.fog($game_system.multifog[n][0],

 $game_system.multifog[n][7])

 

 @neo_multifog2[n].opacity = $game_system.multifog[n][3]

 @neo_multifog2[n].z = (3000 + (n + 1))

 @neo_multifog2[n].blend_type = $game_system.multifog[n][5]

 @neo_multifog2[n].zoom_x = $game_system.multifog[n][6].to_f / 100.00

 @neo_multifog2[n].zoom_y = $game_system.multifog[n][6].to_f / 100.00

 @neo_multifog2[n].ox = $game_map.display_x / 4 + $game_system.multifog[n][1]

 @neo_multifog2[n].oy = $game_map.display_y / 4 + $game_system.multifog[n][2]

 end

 end

 

 #--------------------------------------------------------------------------

 # Apagar novos objetos

 #--------------------------------------------------------------------------

 

 def dispose_new_plane

 if $game_system.multifog.keys.size != 0

 for n in $game_system.multifog.keys

 @neo_multifog2[n].dispose

 end

 $game_system.multifog = {}

 end

 end

 

 #--------------------------------------------------------------------------

 # Apagar novos objetos

 #--------------------------------------------------------------------------

 

 def dispose_one_new_p

 if $game_system.multifog.keys.size != 0

 for n in $game_system.multifog.keys

 @neo_multifog2[n].dispose unless @neo_multifog2[n] == nil or @neo_multifog2[n].disposed?

 end

 end

 end

 

 #--------------------------------------------------------------------------

 # Atualização do Frame

 #--------------------------------------------------------------------------

 

 alias multifog_n_update update

 def update

 multifog_n_update

 if $game_system.eraser_multifog != "none"

 if $game_system.eraser_multifog.is_a?(Integer)

 if @neo_multifog2.keys.include?($game_system.eraser_multifog)

 @neo_multifog2[$game_system.eraser_multifog].dispose

 $game_system.eraser_multifog = "none"

 end

 elsif $game_system.eraser_multifog == "all"

 dispose_new_plane

 $game_system.eraser_multifog = "none"

 end

 end

 

 if $game_system.multifog.values != @neo_multifog

 @neo_multifog = $game_system.multifog.values

 create_new_plane

 end

 for n in $game_system.multifog.keys

 if $game_system.coor_origin[n] == nil

 $game_system.coor_origin[n] = [0,0]

 #$game_system.coor_origin[n].push(0)

 end

 end

 for n in $game_system.multifog.keys

 $game_system.coor_origin[n][0] -= $game_system.multifog[n][1] #/ 8.0

 $game_system.coor_origin[n][1] -= $game_system.multifog[n][2] #/ 8.0

 end

 for n in $game_system.multifog.keys

   next if $game_system.multifog[n] == nil

 #if $game_system.multifog[n][1] != 0

 #  p 'created x'

 #@neo_multifog2[n].ox = $game_map.display_x / 4 + $game_system.multifog[n][1]

 #else

 @neo_multifog2[n].ox = ($game_map.display_x / 4) + $game_system.coor_origin[n][0]

 #end

 #if $game_system.multifog[n][2] != 0

  # p 'created y'

 #@neo_multifog2[n].oy = $game_map.display_y / 4 + $game_system.multifog[n][2]

 #end

 #else

 @neo_multifog2[n].oy = ($game_map.display_y / 4) + $game_system.coor_origin[n][1] 

 end

 end

end

 

#================================================================

# FIM DO SCRIPT =*

#================================================================
 
Here, use this script, it's one i been using, you can make multiple fogs and panorama's.
Code:
#==============================================================================

# Multi-panorama script

#------------------------------------------------------------------------------

# Guillaume777

# 1

# 2005/12/28

#==============================================================================

#

#

# To use it, make a script event with something like

# $game_map.panoramas[0] = Panorama.new('city_pano.png', 0, -500, 2, -3, 1.0/12.0, 1.0/8.0)

#

# [0] is specific place inside the panoramas array where panorama info saved

# city_pano.png is the name of the panorama picture file in \Graphics\Panoramas

# 0 is the hue

# -500 is the z ( higher z : draw on top of lower z )

# 2 is autoscroll x speed

# -3 is the autoscroll y speed

# 1.0/12.0 is ratio of panorama moved / camera moved. Higher ration means faster

# panorama scrolling as you move around horizontaly

# 1.0/8.0 is ratio of panorama moved / camera moved vertically

# 

# You can also use $game_map.panoramas[0].z, $game_map.panoramas[0].name etc to 

# change the panorama

#

# Extra panoramas are going to stay in all maps unless you remove them

# If you want to remove all extra panorama ( for exemple changing the map ) use

# $game_map.panoramas = nil

#

class Game_Map

#--------------------------------------------------------------------------

# Make array to store panoramas in $game_map.panoramas

#--------------------------------------------------------------------------

def panoramas

if @panoramas == nil then @panoramas = Array.new end

return @panoramas

end

 

def panoramas=(array)

for i in 0...self.panoramas.size

if self.panoramas[i] != nil then

self.panoramas[i].dispose

self.panoramas[i] = nil

end

end

@panoramas = array

end

end

 

class Spriteset_Map

#--------------------------------------------------------------------------

# * Update new panoramas and or create the plane with viewport1

#--------------------------------------------------------------------------

alias g7_mp_spriteset_map_update update

def update

g7_mp_spriteset_map_update

 

for i in 0...$game_map.panoramas.size

if $game_map.panoramas[i] != nil then

if $game_map.panoramas[i].plane == nil then

$game_map.panoramas[i].plane = Plane.new(@viewport1)

end

$game_map.panoramas[i].update

end

end

end

 

#--------------------------------------------------------------------------

# Dispose extra panoramas

#-------------------------------------------------------------------------- 

alias g7_mp_spriteset_map_dispose dispose

def dispose

g7_mp_spriteset_map_dispose

for i in 0...$game_map.panoramas.size

if $game_map.panoramas[i] != nil then $game_map.panoramas[i].dispose end

end

end

end

 

 

#--------------------------------------------------------------------------

# This class holds all data relevant to the panorama

#--------------------------------------------------------------------------

class Panorama

attr_accessor :name #name of file to use as panorama

attr_accessor :hue #color hue, 0 default

attr_accessor :z # z value of panorama, used to determine what draws on top

attr_accessor :plane #plane used to draw the panorama

 

attr_accessor :autoscroll_x_speed #autoscroll horizontality value

attr_accessor :autoscroll_y_speed 

attr_accessor :move_speed_x #ratio panorama moved / camera moved, 1.0/8.0 default

attr_accessor :move_speed_y

 

 

#--------------------------------------------------------------------------

# This init the panorama, but doesnt create the plane

#--------------------------------------------------------------------------

def initialize(name='', hue=0, z = 2200, 

autoscroll_x_speed = 0, autoscroll_y_speed = 0,

move_speed_x = 1.0/8.0, move_speed_y = 1.0/8.0)

@z = z

@name = name

@hue = hue

@autoscroll_x_speed = autoscroll_x_speed

@autoscroll_y_speed = autoscroll_y_speed

@move_speed_x = move_speed_x

@move_speed_y = move_speed_y

 

@current_name = ''

@current_hue = 0

@scroll_frames_x = 0

@scroll_frames_y = 0

@scroll_point_x = 0

@scroll_point_y = 0

 

end

 

def dispose

@current_name = ''

#@plane.dispose

@plane = nil

end

 

#--------------------------------------------------------------------------

# Update ox and oy of panorama

#--------------------------------------------------------------------------

def update

if @current_name != @name or

@current_hue != @hue

@current_name = @name

@current_hue = @hue

if @plane.bitmap != nil #if not old panorama then remove old panorama

@plane.bitmap.dispose

@plane.bitmap = nil

end

if @current_name != "" #if new panorama then add the new panorama

@plane.bitmap = RPG::Cache.panorama(@name, @hue)

end

end

 

# Update panorama plane

@plane.z = @z

if @autoscroll_x_speed != 0 or @autoscroll_y_speed != 0

self.scroll #get new scroll_point values

#change the paronama ox and oy for new values

@plane.ox = @scroll_point_x + $game_map.display_x * @move_speed_x

@plane.oy = @scroll_point_y + $game_map.display_y * @move_speed_y

else

@plane.ox = $game_map.display_x * @move_speed_x

@plane.oy = $game_map.display_y * @move_speed_y

end

end 

 

 

#--------------------------------------------------------------------------

# Get new @scroll_point values

#--------------------------------------------------------------------------

def scroll

w = @plane.bitmap.width

h = @plane.bitmap.height

 

@scroll_frames_x += @autoscroll_x_speed

@scroll_frames_y += @autoscroll_y_speed

while @scroll_frames_x >= 8

@scroll_frames_x -= 8

@scroll_point_x += 1

end

while @scroll_frames_x <= -8

@scroll_frames_x += 8

@scroll_point_x -= 1

end

while @scroll_frames_y >= 8

@scroll_frames_y -= 8

@scroll_point_y += 1

end

while @scroll_frames_y <= -8

@scroll_frames_y += 8

@scroll_point_y -= 1

end

if @scroll_point_x > w

@scroll_point_x -= w

end

if @scroll_point_x < -w

@scroll_point_x += w

end

if @scroll_point_y > h

@scroll_point_y -= h

end

if @scroll_point_y < -h

@scroll_point_y += h

end

end

 

end

Just make sure you put anything you use in the panorama folder.
You're gonna have to figure out how to use it though, i don't think i could explain.. i don't think you can change options like opacity, you have to do that manually in an image editor or something.
If you set the Z just right with this script, you can get different things scrolling in the background as well as different things scrolling in the forground at different speeds.
 
I'm all good with my current script. I'm only after fogs you see.
My script can control everything you can from the default fog from the editor, so its also a bit easier to use.
Thanks for the thought though!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top