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
Screenshots
Imagine your game's world as a map with a blinking red dot, in a window. There is you screenshot.
Script
Demo
http://jirby.cleverpun.com/downloads/wmsd.zip
Gives directions on how to use some of the features of this script also.
Notes
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
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