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.

Changing Battle Backgrounds on VX

I'm sure this is a simple thing to do but I can't seem to find the option for it. How do I change the battle backgrounds to relate to the kind of tile you are standing on. eg. a woodland background for forest tiles, plains background for grass tiles, desert for sand etc.

..............?
 

poccil

Sponsor

To change the battle background, edit the create_battleback method of Spriteset_Battle.  Here is an example with comments:
Code:
class Spriteset_Battle
  def create_battleback
    @battleback_sprite = Sprite.new(@viewport1)
    @battleback_sprite.bitmap = Cache.picture("mybattleback.jpg")
  end
end

However, RPGVX doesn't normally support "terrain tags", which would solve the problem with providing different battle backgrounds depending on where the player is.  (Use my multiple tilesets system for terrain tag support,  see this thread.)

One workaround would be to provide a battle background for each map instead.  Example:

Code:
class Spriteset_Battle
  def create_battleback
    mapID=$game_map ? $game_map.map_id : 0
    case mapID
     when 2,3,4 # If map's ID is 2, 3, or 4
       @battleback_sprite = Sprite.new(@viewport1)
       @battleback_sprite.bitmap = Cache.picture("mybattleback1.jpg")
     when 5,6,7 # If map's ID is 5, 6, or 7
       @battleback_sprite = Sprite.new(@viewport1)
       @battleback_sprite.bitmap = Cache.picture("mybattleback2.jpg")
     else # Otherwise
       @battleback_sprite = Sprite.new(@viewport1)
       @battleback_sprite.bitmap = Cache.picture("mybattleback3.jpg")
     end
  end
end
 
Okay sounds straight forward enough. Just a couple of questions.

A) For the first script......Instead of inserting this into the "scripts" section would this work as an event? ie. If I had an enemy "Desert Bandit" could I add the event to their troop encounter so the back would change to a desert setting. Or if the enemy was "Snow leopard" use the script to change to snow back?

B) Does the second script require your download to work or are the maps ID'd as part of the original context of VX?

C) I read the thread on your multiple tilests but didn't quite understand the whole "terrain tags" thing. COuld you please explain what it does?

oh and thanks :)
 

poccil

Sponsor

Both scripts do not require the "multiple tilesets" system.  They just describe different ways to change the battle background.

Each map has its own ID, for example, the map created upon creating a new project has an ID of 1.

A terrain tag is a number assigned to each tile in a tileset.  They are generally used to mark terrain and such.  For example, all desert tiles would have one terrain tag, and all water tiles would have another terrain tag.  Initially, all tiles have a terrain tag of 0.

The following example shows how the battle background can change depending on the troop in the battle:
Code:
class Spriteset_Battle
  def create_battleback
    troopID=$game_troop ? $game_troop.troop.id : 0
    background="mybattleback1.jpg"
    case mapID
     when 1 # If troop ID is 1
       background="mybattleback2.jpg"
     when 2,3 # If troop ID is 2 or 3
       background="mybattleback3.jpg"
    end
    @battleback_sprite = Sprite.new(@viewport1)
    @battleback_sprite.bitmap = Cache.picture(background)
  end
end
 

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