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.

Map in background

Hi, I know this has probably been asked many times but I searched and couldn't find it.

What do I need to put in a scene to have the map in the background of the scene?
 
that only shows the current map that you are on, or the first map that is set as the start point. What if you wanted to have a map that is set up specifically for something like this? Say... You have a map that is created just to show ... how many crystals you have obtained out of so many.. and see them set on lil fancy display shelves, and you have a command in the menu that says "Show Crystals" Now if you use what you just gave now.
Code:
@sprite_set = Spriteset_Map.new
That is just gonna give you a view of the current map that you are on.. How would you make it give you a completly different map.. and when you press escape or enter it brings you back to the menu and when you escape that you will be on your given map that you were on at first...

If that makes any sense.. if not im sorry lol..
 
First, you would need to store your player and map data as a temp variable, or save player position and map id. I suggest saving them in Game_System or something, and recover from there.

Then, switch the map and the player location and whatnot, and there you go.

Code:
class Game_System
  attr_accessor :saved_mapid
  attr_accessor :player_location
end

Add that somewhere. Then, before you go to your whatever, use something like:

Code:
# Saves Map and Location
$game_system.saved_mapid = $game_map.map_id
$game_system.player_location = [$game_player.x, $game_player.y]

# Move Player
$game_map.setup(map_id)
$game_player.move_to(x, y)

# Restore Map and Player
$game_map.setup($game_system.saved_mapid)
$game_player.move_to($game_system.player_location[0], $game_system.player_location[1])

Whenever you switch, just replace

$game_map.setup(map_id)
$game_player.move_to(x, y)

map_id = map you are going to
x, y = location on map
 

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