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.

Panorama change based on variables

Hello peoples, how is your collective day going?
It should be obvious by the topic icon that I am looking for a script for VX.  Just figured I'd throw that out incase someone didn't notice, I wouldn't want you wasting your time.  What I am requesting is as follows:

A script that will change the panorama of maps depending on a set variable.  Only certain maps will be altered, and they won't all be altered to the same thing, so the script must be able to handle this.

Basically when a variable is increased, the panorama for that map would change.  Another map would have different panoramas, and have different numbers needed for this to take affect, but would work off the same variable.

Possibly, this could be set up so that each map ID can be given a set.
Map ID 1 could have a {1 => 2, 5 => 3, 6 => 4}
Where when the variable is 1, it becomes 2.png, and when the variable is 5 it becomes 3.png, and at 6 becomes 4 png, see where I'm going with that?
Simultaneously,
Map ID 2 could have a {1 => 12, 13 => 13, 29 => 14}
Where at variable 1, the panorama is 12, etc.

Now I don't know if the above would work, having it be 2.png or what, I just thought it might?  Although if there is a better or easier way for anyone who would want to take up this request, by all means go with whatever is easier.

Also if I typed this horribly and am not clear, by all means inform me.

Thanks.
 
Here it is!
Code:
#==============================================================================
# ** Variable to Parallax
#------------------------------------------------------------------------------
#  © Dargor, 2008
#  05/06/08
#  Version 1.0
#  Requested by sixtyandaquarter
#==============================================================================

#==============================================================================
# ** Parallax Configuration Module
#==============================================================================

module Parallax
  # ID of the variable used to define parallaxes
  Variable_ID = 1
  # List of parallaxes per maps, depending on the variable's value
  # SYNTAX: {Map_ID => {variable_value => parallax_name}}
  Parallaxes = {
          4 => {5 => 'BlueSky'  ,10 => 'Cave'},
          5 => {2 => 'Mountain' ,4  => 'Ocean'}
          }
  # Default Parallax Name
  Parallaxes.default = ''
end
        
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :parallax_name
  attr_accessor :parallax_sx
  attr_accessor :parallax_sy
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_var_to_par_spriteset_map_update_parallax update_parallax
  #--------------------------------------------------------------------------
  # * Update Parallax
  #--------------------------------------------------------------------------
  def update_parallax
    variable_to_parallax(Parallax::Variable_ID)
    dargor_vx_var_to_par_spriteset_map_update_parallax
  end
  #--------------------------------------------------------------------------
  # * Variable to Parallax
  #--------------------------------------------------------------------------
  def variable_to_parallax(variable_id)
    map_id = $game_map.map_id
    value = $game_variables[variable_id]
    return unless Parallax::Parallaxes.has_key?(map_id)
    if Parallax::Parallaxes[map_id][value].nil?
      $game_map.parallax_name = Parallax::Parallaxes.default
    else
      $game_map.parallax_name = Parallax::Parallaxes[map_id][value]
    end
  end
end
I can also add different looping/scrolling based the the variable's value if you want.
It works as you said, Map_ID => {variable_value => parallax_name}

Hope you like it!
-Dargor
 
Just ran a the test, and that's absolutely perfect, Dargor.  Thanks :)

I personally don't need looping or scrolling based on variables for what I'm doing, but I can certainly see lots of uses for it both aesthetically and practically.

Thanks again for taking the time to help out :)
 

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