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.

[VX] World Map Screen

Taylor

Sponsor

World Map Screen
by Jirbytaylor
Version 2.0

Introduction
This script is to create a screen in your menu that displays your position on the world map. This is more for games that don't use a map-based world map however. Think along the lines of Pokémon games' Town Map.

Features
  • Turn the map on and off, disabling it when the player may not have a map item. To toggle the visibility of the map, put "$game_system.havemap = true/false" in a script in an event, with either true or false as the value.
  • To change the message that displays when you have no map, simply look for '"You have no map of this region."' in Window_WorldMap of the script, and edit it to your liking. The message is set to center.
  • Multiple "regions" can be created with multiple maps. To change region, put "$game_system.currentmap = x" in a script in an event, where 'x' is the index of your map. Map files and indexes are configured in the script in the Jaabi module.

Screenshots
Imagine your game's world as a map with a blinking red dot, in a window. There is you screenshot.
http://img183.imageshack.us/img183/699/lolmapscreenshotha0.jpg[/img]

Script

Code:
#==============================================================================
# ** World Map
#------------------------------------------------------------------------------
#  © Jirbytaylor / Jaabi (and a bit of Yeyinde's help XD)
#  Version 2.1
#==============================================================================

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :currentmap           # World Map Image ID
  attr_accessor :havemap              # Wether or not to show map
  #--------------------------------------------------------------------------
  # * Aliasing
  #--------------------------------------------------------------------------
  alias wms_init initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # DO NOT CHANGE THESE! CHANGE THEM WITH EVENTS!
    # Map ID, relative to MAPFILE
    @currentmap = 0
    # Wether or not the map can be seen
    @havemap = false
    wms_init
  end
end

#==============================================================================
#  ** Jaabi Script Configurations
#==============================================================================

module Jaabi
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  # Name of map file, under Graphics/System
  MAPFILE = {0 => "WMap0.png",
             1 => "WMap1.png",}
  # Name of position indicator file, under Graphics/System
  POSFILE = "WMapPos.png"
  # Position of indicator
  # Format: MAP_ID => [x, y,], MAP_ID => [x, y,], etc.
  # X and Y coordinates are in pixels.
  MAP_POS = { 1 => [119, 240],
              2 => [161,  93],
              3 => [ 90, 314],
              5 => [289, 213],}
  # Failsafe, prevent errors. It's best to leave this alone
  # So maps without a defined position don't display the red dot
  MAP_POS.default = [-32, -32]
end

#==============================================================================
# ** Window_WorldMap
#------------------------------------------------------------------------------
#  This window displays the map and position icon.
#==============================================================================

class Window_WorldMap < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 544, 416)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # Check if you have *a* map. Must be reset with events with
    # a conditional branch checking for an item or switch etc.
    if $game_system.havemap == true
      # Display the map file relative to the current map index
      bitmap = Cache.system(Jaabi::MAPFILE[$game_system.currentmap])
      self.contents.blt(6, 6, bitmap, bitmap.rect)
    else
      # Display message if you have no map
      message = "You have no map of this region."
      self.contents.draw_text(0, 182, 514, WLH, message, 1)
    end
  end
end

#==============================================================================
# ** Scene_WorldMap
#------------------------------------------------------------------------------
#  This class performs the world map screen processing.
#==============================================================================

class Scene_WorldMap < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @wm_window = Window_WorldMap.new
    $data_mapinfos = load_data("Data/MapInfos.rvdata")
    @pos = Sprite.new
    @pos.bitmap = Cache.system(Jaabi::POSFILE)
    @pos.opacity = 0
    @target_opacity = 255
    @pos.z = 105
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    @wm_window.dispose
    @pos.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update Processing
  #--------------------------------------------------------------------------
  def update
    super
    # Control closing of scene
    if Input.trigger?(Input::B) or Input.trigger?(Input::C)
      Sound.play_cancel
      return_scene
    end
    # Check if co-ordinates are < 0, if so use parent map
    # co-ordinate settings if avaliable
    if Jaabi::MAP_POS[$game_map.map_id][0] <= -1
      @pos.x = Jaabi::MAP_POS[$data_mapinfos[$game_map.map_id].parent_id][0] + 22
      @pos.y = Jaabi::MAP_POS[$data_mapinfos[$game_map.map_id].parent_id][1] + 22
    else
      @pos.x = Jaabi::MAP_POS[$game_map.map_id][0] + 22
      @pos.y = Jaabi::MAP_POS[$game_map.map_id][1] + 22
    end
    # Check if you have *a* map
    if $game_system.havemap == true
      # Fade in and out position indicator for effect
      if @pos.opacity <= @target_opacity
        @pos.opacity += 10
        @target_opacity = 20 if @pos.opacity >= @target_opacity
      elsif @pos.opacity >= @target_opacity
        @pos.opacity -= 10
        @target_opacity = 250 if @pos.opacity <= @target_opacity
      end
    else
      # Hide position
      @pos.opacity = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Return to Original Screen
  #--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Menu.new(4)
  end
end

Demo
http://jirby.cleverpun.com/downloads/wmsd.zip
Gives directions on how to use some of the features of this script also.

Notes
  • No I am not making an XP version.
  • May not work with old saves and/or may corrupt them. Test the script in a new game if you encounter issues.

And that's it people, feel free to give any suggestions on improvements, or report any bugs here. It's been a while since I tried to really script something, and I thank Yeyinde for all the help over the things I didn't quite get. XD;

~ Jaabi
 
It's a very good script man, I like that!

But I have some suggestions (although I know nothing about scripting xD).

Like, it would be great if the World Map shows was like an image of the whole area put together, but smaller, instead of just drawings =P

Another thing that would be really good would be a little box you could turn on and off with some button and that would show you your position and the map moving as you walk around.

Just suggestions, I atually believe it's quite good :D
 

Taylor

Sponsor

NunoAle":16fknqvm said:
Like, it would be great if the World Map shows was like an image of the whole area put together, but smaller, instead of just drawings =P

Another thing that would be really good would be a little box you could turn on and off with some button and that would show you your position and the map moving as you walk around.

Just suggestions, I atually believe it's quite good :D
1. Are you meaning like a view of all the maps put together? I'm afraid I'm no where near that good at scripting, plus it's not really the purpose of this script. Having a map image allows for creation of an image that may look "mapy". Parchment-like, labels and so on.
2. That I am guessing is like a mini-map? Again the script was made not with that purpose, as to create that would require an almost completely different script.

Might I note the map position is based on the map you're in rather than the position in the map - that's why I said it's like the Pokemon Game's Town Map. (Rather than Final Fantasies or Tales of Phantasia.)

EDIT: Made some modifications to lines 137-143, this edit was updated to the script but not the demo. This minor changes makes it easier to base the co-ordinates specified in my module on the map, because [0,0] will actually be [0,0] on the graphic rather than the whole screen. (Unless you make your own changes to the size/position of the map graphic, then you'll need to change the position offset yourself.)
This is the change:
Code:
    if Jaabi::MAP_POS[$game_map.map_id][0] <= -1
      @pos.x = Jaabi::MAP_POS[$data_mapinfos[$game_map.map_id].parent_id][0] + 22
      @pos.y = Jaabi::MAP_POS[$data_mapinfos[$game_map.map_id].parent_id][1] + 22
    else
      @pos.x = Jaabi::MAP_POS[$game_map.map_id][0] + 22
      @pos.y = Jaabi::MAP_POS[$game_map.map_id][1] + 22
    end
 

Taylor

Sponsor

You will need to add the option in the menu yourself. If you don't have a CMS, copy over the Scene_Menu from the demo.

Otherwise have a look at the menu in the demo, and compare it to the default, and analyse what I changed to have the "World Map" option.
Sorry.... I'm no good at explaining how to add things to the menu easily. ._.;

The screen is called with $scene = Scene_Worldmap.new.
 

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