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.

Show World Map (With Location)

Nolund

Sponsor

OK, I'm in need of a script. My searches seemed to be in vain, so I may just have missed one that was previously made.

Anyway, what I need is a script that will bring up the map, with the players' location on it. If possible, I'd like to have individual maps for regions, where you can zoom out to the world map (similar to the mapping system in Legend of Zelda: Twilight Princess).

Think of it like this (and I do not claim I've made this map, I found it online).

World Map:
fantasy-world-4.JPG

Say I hit a button to bring up that map, I'd like an icon to appear on it showing the player's location. Then, if a player wishes to zoom in, he can look at the region (so say someone zooms in on Raeldar, they can see their exact location in the region). They could then zoom in again to their exact map.

If there is a script out there that can do what I need, I must've missed it, to which I apologize. If not, is there anyone who'd be willing to make one?
 
Hey. Saw your request and had an idea on how to achieve it, mix of scripts and switches. The switches would come into play and act as a the way to define regions, i.e. Switch 1 is the Region of Blah Blah Cliché and Switch 2 is the Region of Super Epic Bad Guy. The script which displays the main map image would check which Switch is active and if the button is pressed it'll display the map of that region and a dot on the map as to where the hero is. Now I thought this would be easy to put into practise, but I keep running into silly errors. No doubt they are notourisly easy to fix but I'm sick and have lost the concentration for it at the moment. If you want to check it out heres what I've done thus far with the code (anybody else is free to have a look, would love advice on how to improve it (other than actually making it work..)).

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

# ** Scene_Worldmap

# ** Created by Desecration, credit is purely optional.

# ** V 0.1 Bug Ridden, if it works for you, congratulations, if not, oh well.

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

#  This class will display the worldmap on your screen.

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

 

class Scene_WorldMap

  

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

  # * Main Processing

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

  

  def main

    

    # Define the worldmap image

    @worldmap = Sprite.new

    @worldmap.bitmap = RPG::Cache.picture("fantasy-world-4")

    @worldmap.x = 0

    @worldmap.y = 0

 

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to map screen

      $scene = Scene_Map.new

      return

    end

  

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

  # * Displaying Actor Graphic, Map Name and Sub-Regions

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

  

  def update

    self.contents.clear

    self.contents.draw_text(180, 0, 120, 32, $game_map.mpname.to_s, 2)

    draw_actor_graphic(@actor, 40, 112)

    draw_actor_name(@actor, 4, 0)

  end

 

    # Displaying the sub-regions

    if Input.trigger?(Input::X)

     if switch_id = 0

      # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

    if switch_id = 1

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Show the correct sub-region depending on which switch is active.

      @region1 = Sprite.new

      @region1.bitmap = RPG::Cache.picture("001-Title01")

      @region1.x = 0

      @region1.y = 0

      return

    end

    if switch_id = 2

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Show the correct sub-region depending on which switch is active.

      @region2 = Sprite.new

      @region2.bitmap = RPG::Cache.picture("001-Title01")

      @region2.x = 0

      @region2.y = 0

      return

    end

  end

end

end

 
 
There are several things wrong with that. I'll point some out to you...

[rgss]#==============================================================================
# ** Scene_Worldmap
# ** Created by Desecration, credit is purely optional.
# ** V 0.1 Bug Ridden, if it works for you, congratulations, if not, oh well.
#------------------------------------------------------------------------------
#  This class will display the worldmap on your screen.
#==============================================================================
 
class Scene_WorldMap
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Define the worldmap image
    @worldmap = Sprite.new
    @worldmap.bitmap = RPG::Cache.picture("fantasy-world-4")
    @worldmap.x = 0
    @worldmap.y = 0
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;">This part needs to be in update, NOT main
<span style="color:#000080; font-style:italic;">    # If B button was pressed
<span style="color:#000080; font-style:italic;">    if Input.trigger?(Input::B)
<span style="color:#000080; font-style:italic;">      # Play cancel SE
<span style="color:#000080; font-style:italic;">      $game_system.se_play($data_system.cancel_se)
<span style="color:#000080; font-style:italic;">      # Switch to map screen
<span style="color:#000080; font-style:italic;">      $scene = Scene_Map.new
<span style="color:#000080; font-style:italic;">      return
<span style="color:#000080; font-style:italic;">    end
<span style="color:#000080; font-style:italic;"> =end
  end #this needs to be here
  #--------------------------------------------------------------------------
  # * Displaying Actor Graphic, Map Name and Sub-Regions
  #--------------------------------------------------------------------------
  def update
<span style="color:#000080; font-style:italic;">=begin Trying to make a window?  Try this instead:
<span style="color:#000080; font-style:italic;">make the window in main:
<span style="color:#000080; font-style:italic;">    @title_window = Window_Base.new(0, 0, 640, 64)
<span style="color:#000080; font-style:italic;">    @title_window.contents = Bitmap.new(640 - 32, 64 - 32)
<span style="color:#000080; font-style:italic;">    @title_window.draw_text(0, 0, 640 - 32, 32, $game_map.mpname.to_s, 1) # Note: 0=left, 1=middle, 2=right
<span style="color:#000080; font-style:italic;"># Who is @actor?  Is it the first member of the party?
<span style="color:#000080; font-style:italic;">    draw_actor_graphic(@actor, 40, 112)
<span style="color:#000080; font-style:italic;">    draw_actor_name(@actor, 4, 0)
<span style="color:#000080; font-style:italic;">=end
#  end This needs to be deleted
 
    # Displaying the sub-regions
    if Input.trigger?(Input::X) # Why X, and not C?
     if switch_id = 0 # Use == instead of =
      # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
    if switch_id = 1 # Use == instead of =
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Show the correct sub-region depending on which switch is active.
      @region1 = Sprite.new
      @region1.bitmap = RPG::Cache.picture("001-Title01")
      @region1.x = 0
      @region1.y = 0
      return
    end
    if switch_id = 2 # Use == instead of =
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Show the correct sub-region depending on which switch is active.
      @region2 = Sprite.new
      @region2.bitmap = RPG::Cache.picture("001-Title01")
      @region2.x = 0
      @region2.y = 0
      return
    end
  end
end
#end Remove this
 
[/rgss]
 
Thanks Rey, I made the changes that you suggested and spotted a few very silly errors of my own. Here is the mark 2 version of the script NNolound, I'll try and cater it more to your needs if this isn't right for you yet. Just get back to me.

New code, paste above main.

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

# ** Scene_Worldmap

# ** Created by Desecration, credit is purely optional.

# ** V 0.2 Works now, thanks rey meustrus

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

#  This class will display the worldmap on your screen,

#  when @Scene_WorldMap.new is called.

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

 

class Scene_WorldMap

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

  # * Main Processing

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

  def main

    # Define the worldmap image

    @worldmap = Sprite.new

    @worldmap.bitmap = RPG::Cache.picture("fantasy-world-4")

    @worldmap.x = 0

    @worldmap.y = 0 

    # Graphics Transition

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      # Update Method

      update

      if $scene != self

        break

      end

    end

    @worldmap.dispose

  end 

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

  # * Displaying Actor Graphic, Map Name and Sub-Regions

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

  def update

    # If B button was pressed

    if Input.trigger?(Input::B)

    # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

    # Switch to map screen

      $scene = Scene_Map.new

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

     if $game_switches[0]

      # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

    if $game_switches[1]

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Show the correct sub-region depending on which switch is active.

      @region1 = Sprite.new

      @region1.bitmap = RPG::Cache.picture("001-Title01")

      @region1.x = 0

      @region1.y = 0

      end

      return

    end

    if $game_switches[2]

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Show the correct sub-region depending on which switch is active.

      @region2 = Sprite.new

      @region2.bitmap = RPG::Cache.picture("001-Title01")

      @region2.x = 0

      @region2.y = 0

    end

  end

end

 
 
Desecration,

[ edit ] Sorry if I was redundant, I didn't see Rey's reply... :scruff:

A couple problems to start with:

Your "main" method is going to get called every cycle (as fast as it can process), and it doesn't have a Graphics.update call.
RMXP Help said:
If this method is not called in 10 seconds or more, the program will view the script as having run out of control and will force a quit.

If you look at the rest of the Scene_* scripts, they all use a loop in the main method that calls Graphics.update, Input.update, and the update method for this class.


Now, you are drawing the contents of the map sprite in the update method. So, when you have a loop that calls 'update', it will redraw everything every frame. I would recommend putting the draw statements in a 'refresh' method, and only use the update method to check if a button has been pressed, and process the input.
Then call the refresh method only when the screen needs to be changed.

Now if we look at the update method
You use $game_map.mpname without ever initializing it
draw_actor_graphic is going to try to draw the front facing cell from the character set
You test switch_id without ever initializing it.

NNolund,

A few things also need to be verified with the system designer (NNolund):
Do you want to use a single image & have 3 zoom levels? (huge image),
Or do you want to have a separate image for each region & subregion(map)? (lots of images)

You said you want an icon for the players position, but didn't supply one.

You didn't specify which buttons get used for what. I would make the following assumptions...
Action Button(C): nothing
Esc / Exit (X): leave the worldmap scene
Up Arrow: Zoom in
Down Arrow: Zoom out

Your world map is larger than 640x480. Do you want the starting view to try to center the players location?
 

Nolund

Sponsor

Brewmeister":2w8hclng said:
A few things also need to be verified with the system designer (NNolund):
Do you want to use a single image & have 3 zoom levels? (huge image),
Or do you want to have a separate image for each region & subregion(map)? (lots of images)

I assumed that having separate images would be easier/more convenient, so I planned on using that method.

Brewmeister":2w8hclng said:
You said you want an icon for the players position, but didn't supply one.

I was just going to use a red dot or something. Didn't think I needed to supply it. I can do that for you though if you need.

Brewmeister":2w8hclng said:
You didn't specify which buttons get used for what. I would make the following assumptions...
Action Button(C): nothing
Esc / Exit (X): leave the worldmap scene
Up Arrow: Zoom in
Down Arrow: Zoom out

My bad on that, I apologize. That would be a good way to do it, but it doesn't really allow panning. I was thinking this (if it is possible)

Action Button (C): Zoom in
Esc/Exit (X): Zoom out/exit (exit if in world map view)
Arrows: Pan around map (by region, so it selects a portion of the map)

Brewmeister":2w8hclng said:
Your world map is larger than 640x480. Do you want the starting view to try to center the players location?

Never thought about that. Yeah, that would make the most sense.

I apologize for forgetting a bunch of stuff. I am not really used to asking for scripts. I hope that helps some more.
 

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