Interactive World Map Script Version: 1.0
By: Plague180
This script creates a world map, to not be mistaken with a map.rxdata file, but an interactive world map that allows users to choose what town they would like to travel to and then go there, much like dragon age, guild wars, oblivion or fable 3.
Features:
There are 3 cursor types:
1.Static choices-cursor can only move over towns(example used in demo)
2.Free moving cursor-works like mouse but moves with keyboard
3.Mouse-self explanatory
There are 2 Name types
1. Under cursor
2.Nam Box at top of screen(example used in demo)
Plus tons of other small customizable items
Screenshots

Demo
this isnt the best demo in the world(but it should give you a good idea how all this works) im waiting for graphics/ feed back to make better demo.
http://www.megaupload.com/?d=796VBH7M
Script
Instructions
FAQ
Q: I get an error on line 305 in world_map, what wrong?
A: You don't have any towns UNLOCKED yet.
Q:I get an error on line 299 in sub_map, what wrong?
A: You don't have any sub sections for that town unlocked UNLOCKED. Shouldn't ever have an issue here because if there is no subsection it is sapose to go straight to the default, but one person did get this error.
Compatibility
Haven't tested it with anything out side of my other custom scripts, but if you have a mouse system it might clash with this(if u use my mouse, but if u dont then it might not accept your clicks)
Credits and Thanks
SephirothSpawn - Created Data Structure
CyberSam - Keyboard Input Module
CyberSam - Mouse Module
Mr.Mo - Error Log
Tomas - World Map Background
Special Thanks to Silver Wind for all his help with my Sub Sections
Special Thanks to SephirothSpawn for all his support coding and moral, Thanks man!
Author's Notes
I work alot, but i will help you with any problems asap.
if you have a game that uses my script i would love to see what my script can do with good graphics :)
Terms and Conditions
I do not what this script hosted anywhere other then http://www.hbgames.org with out my permission. free for use commercial and noncommercial.
By: Plague180
This script creates a world map, to not be mistaken with a map.rxdata file, but an interactive world map that allows users to choose what town they would like to travel to and then go there, much like dragon age, guild wars, oblivion or fable 3.
Features:
There are 3 cursor types:
1.Static choices-cursor can only move over towns(example used in demo)
2.Free moving cursor-works like mouse but moves with keyboard
3.Mouse-self explanatory
There are 2 Name types
1. Under cursor
2.Nam Box at top of screen(example used in demo)
Plus tons of other small customizable items
Screenshots

Demo
this isnt the best demo in the world(but it should give you a good idea how all this works) im waiting for graphics/ feed back to make better demo.
http://www.megaupload.com/?d=796VBH7M
Script
lots of code
Spoiler
- #==============================================================================
- # Keyboard Input Module
- #----------------------------------------------------------------------------
- # Script by Cybersam
- #==============================================================================
- module Input
- @keys = []
- @pressed = []
- Mouse_Left = 1
- Mouse_Right = 2
- Mouse_Middle = 4
- Back= 8
- Tab = 9
- Enter = 13
- Shift = 16
- Ctrl = 17
- Alt = 18
- Esc = 27
- Space = 32
- Numberkeys = {}
- Numberkeys[0] = 48 # => 0
- Numberkeys[1] = 49 # => 1
- Numberkeys[2] = 50 # => 2
- Numberkeys[3] = 51 # => 3
- Numberkeys[4] = 52 # => 4
- Numberkeys[5] = 53 # => 5
- Numberkeys[6] = 54 # => 6
- Numberkeys[7] = 55 # => 7
- Numberkeys[8] = 56 # => 8
- Numberkeys[9] = 57 # => 9
- Numberpad = {}
- Numberpad[0] = 45
- Numberpad[1] = 35
- Numberpad[2] = 40
- Numberpad[3] = 34
- Numberpad[4] = 37
- Numberpad[5] = 12
- Numberpad[6] = 39
- Numberpad[7] = 36
- Numberpad[8] = 38
- Numberpad[9] = 33
- Letters = {}
- Letters["A"] = 65
- Letters["B"] = 66
- Letters["C"] = 67
- Letters["D"] = 68
- Letters["E"] = 69
- Letters["F"] = 70
- Letters["G"] = 71
- Letters["H"] = 72
- Letters["I"] = 73
- Letters["J"] = 74
- Letters["K"] = 75
- Letters["L"] = 76
- Letters["M"] = 77
- Letters["N"] = 78
- Letters["O"] = 79
- Letters["P"] = 80
- Letters["Q"] = 81
- Letters["R"] = 82
- Letters["S"] = 83
- Letters["T"] = 84
- Letters["U"] = 85
- Letters["V"] = 86
- Letters["W"] = 87
- Letters["X"] = 88
- Letters["Y"] = 89
- Letters["Z"] = 90
- Fkeys = {}
- Fkeys[1] = 112
- Fkeys[2] = 113
- Fkeys[3] = 114
- Fkeys[4] = 115
- Fkeys[5] = 116
- Fkeys[6] = 117
- Fkeys[7] = 118
- Fkeys[8] = 119
- Fkeys[9] = 120
- Fkeys[10] = 121
- Fkeys[11] = 122
- Fkeys[12] = 123
- Collon = 186 # => \ |
- Equal = 187 # => = +
- Comma = 188 # => , <
- Underscore = 189 # => - _
- Dot = 190 # => . >
- Backslash = 191 # => / ?
- Lb = 219
- Rb = 221
- Quote = 222 # => '"
- #-------------------------------------------------------------------------------
- USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle]
- #-------------------------------------------------------------------------------
- module_function
- #--------------------------------------------------------------------------
- def triggered?(key)
- Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
- end
- #--------------------------------------------------------------------------
- def check(key)
- Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
- end
- #--------------------------------------------------------------------------
- def pressed?(key)
- return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)
- return false
- end
- #--------------------------------------------------------------------------
- def mouse_update
- @used_i = []
- for i in USED_KEYS
- x = check(i)
- if x == true
- @used_i.push(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- def self.C
- self.trigger?(C)
- end
- #--------------------------------------------------------------------------
- def self.B
- self.trigger?(B)
- end
- #--------------------------------------------------------------------------
- def self.A
- self.trigger?(A)
- end
- #--------------------------------------------------------------------------
- def self.Down
- self.trigger?(DOWN)
- end
- #--------------------------------------------------------------------------
- def self.Up
- self.trigger?(UP)
- end
- #--------------------------------------------------------------------------
- def self.Right
- self.trigger?(RIGHT)
- end
- #--------------------------------------------------------------------------
- def self.Left
- self.trigger?(LEFT)
- end
- #--------------------------------------------------------------------------
- def self.Anykey
- if A or B or C or Down or Up or Right or Left
- return true
- else
- return false
- end
- end
- #--------------------------------------------------------------------------
- end
Expand to see the code.
- #-------------------------------------------------------------------------------
- # Author Cybersam
- # Version 1.0
- # Date 11-04-06
- # Edit Astro_mech
- #===============================================================================
- module Mouse
- #--------------------------------------------------------------------------
- # * Variable Setup
- #--------------------------------------------------------------------------
- gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
- @cursor_pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
- module_function
- #--------------------------------------------------------------------------
- # * Mouse Global Position
- #--------------------------------------------------------------------------
- def mouse_global_pos
- pos = [0, 0].pack('ll')
- if @cursor_pos.call(pos) != 0
- return pos.unpack('ll')
- else
- return nil
- end
- end
- #--------------------------------------------------------------------------
- # * Mouse Position
- #--------------------------------------------------------------------------
- def mouse_pos(catch_anywhere = false)
- width, height = client_size
- x, y = screen_to_client(*mouse_global_pos)
- return x,y
- end
- #--------------------------------------------------------------------------
- # * Delete
- #--------------------------------------------------------------------------
- def del
- if @oldcursor == nil
- return
- else
- @SetClassLong.call(handel ,-12, @oldcursor)
- @oldcursor = nil
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Variable Setup
- #--------------------------------------------------------------------------
- $scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
- $client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
- $readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
- $findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
- #--------------------------------------------------------------------------
- # * Screen to Client
- #--------------------------------------------------------------------------
- def screen_to_client(x, y)
- return nil unless x and y
- pos = [x, y].pack('ll')
- if $scr2cli.call(hwnd, pos) != 0
- return pos.unpack('ll')
- else
- return nil
- end
- end
- #--------------------------------------------------------------------------
- # * H Windowed
- #--------------------------------------------------------------------------
- def hwnd
- game_name = "\0" * 256
- $readini.call('Game','Title','',game_name,255,".\\Game.ini")
- game_name.delete!("\0")
- return $findwindow.call('RGSS Player',nil)
- end
- #--------------------------------------------------------------------------
- # * Client Size
- #--------------------------------------------------------------------------
- def client_size
- rect = [0, 0, 0, 0].pack('l4')
- $client_rect.call(hwnd, rect)
- right, bottom = rect.unpack('l4')[2..3]
- return right, bottom
- end
Expand to see the code.
- cursor = Win32API.new("user32", "ShowCursor", "i", "i" )
- cursor.call(0) # hide mouse
- #--------------------------------------------------------------------------
- class Mouse_Reader
- MOUSE_ICON = "Arrow" #The default mouse icon.
- CURSOR = Win32API.new("user32", "ShowCursor", "i", "i" )
- #--------------------------------------------------------------------------
- # * Attributes
- #--------------------------------------------------------------------------
- attr_accessor :x
- attr_accessor :y
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- @x = 0
- @y = 0
- @sprite = Sprite.new
- @sprite.z = 5000
- @draw = false
- draw
- end
- #--------------------------------------------------------------------------
- # * draw
- #--------------------------------------------------------------------------
- def draw
- @icon = RPG::Cache.icon(MOUSE_ICON)
- @icon_name = MOUSE_ICON
- @sprite.bitmap.dispose if @sprite.bitmap != nil and @sprite.bitmap.disposed?
- @sprite.bitmap = @icon
- @draw = false
- @x, @y = Mouse.mouse_pos
- @sprite.x = @x
- @sprite.y = @y
- @sprite.z = 5000
- @sprite.visible = true
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- # Updates the co-ordinates of the icon
- @x, @y = Mouse.mouse_pos
- return if @x == nil or @y == nil
- #Get Client Size
- width,height = Mouse.client_size
- @sprite.x = @x
- @sprite.y = @y
- #Check if needs to restart
- (@draw = (@x < 0 or @y < 0 or @x > width or @y > height)) if !@draw
- #draw if need to draw
- draw if @draw and @x > 1 and @y > 1 and @x < width and @y < height
- #Show mouse if need to
- if (@x < 0 or @y < 0 or @x > width or @y > height) and @visible
- CURSOR.call(1)
- @visible = false
- elsif (@x > 0 or @y > 0 or @x < width or @y < height) and !@visible
- CURSOR.call(0)
- @visible = true
- end
- #Return if Scene is not Scene_Map
- if $scene != $scene.is_a?(Scene_Map)
- return
- end
- end
- def disable
- @sprite.visible = false
- end
- end
Expand to see the code.
- #==============================================================================
- # ** Data::Object, Map_Items::Town, Sub::Town
- #------------------------------------------------------------------------------
- # These classes were created by SephirothSpawn
- #==============================================================================
- module Map_Items
- Towns = {}
- end
- module Sub
- Towns = {}
- end
- class Data::Object
- @@ids = {}
- @@containers = {}
- attr_accessor :id
- def initialize
- @@ids[self.class] = 0 unless @@ids.has_key?(self.class)
- @@ids[self.class] += 1
- @id = @@ids[self.class]
- if @@containers.has_key?(self.class)
- @@containers[self.class][@id] = self
- end
- end
- def self.add_container(class_name, container)
- @@containers[class_name] = container
- end
- end
- class Map_Items::Town < Data::Object
- Data::Object.add_container(self, Map_Items::Towns)
- attr_reader :screen_x
- attr_reader :screen_y
- attr_reader :map_id
- attr_reader :map_x
- attr_reader :map_y
- attr_reader :direction
- attr_reader :icon
- attr_reader :town_name
- attr_reader :switch
- def initialize(screen_x, screen_y, map_id, map_x, map_y, direction, icon, town_name, switch)
- super()
- @screen_x = screen_x
- @screen_y = screen_y
- @map_id = map_id
- @map_x = map_x
- @map_y = map_y
- @direction = direction
- @icon = icon
- @town_name = town_name
- @switch = switch
- end
- def self.screen_x
- return @screen_x
- end
- def self.screen_y
- return @screen_y
- end
- def self.map_id
- return @map_id
- end
- def self.map_x
- return @map_x
- end
- def self.map_y
- return @map_y
- end
- def self.direction
- return @direction
- end
- def self.icon
- return @icon
- end
- def self.town_name
- return @town_name
- end
- def self.switch
- return @switch
- end
- end
- class Sub::Town < Data::Object
- Data::Object.add_container(self, Sub::Towns)
- attr_reader :screen_x
- attr_reader :screen_y
- attr_reader :map_id
- attr_reader :map_x
- attr_reader :map_y
- attr_reader :direction
- attr_reader :icon
- attr_reader :town_name
- attr_reader :switch
- attr_reader :upper_level
- def initialize(screen_x, screen_y, map_id, map_x, map_y, direction, icon, town_name, switch, upper_level)
- super()
- @screen_x = screen_x
- @screen_y = screen_y
- @map_id = map_id
- @map_x = map_x
- @map_y = map_y
- @direction = direction
- @icon = icon
- @town_name = town_name
- @switch = switch
- @upper_level = upper_level
- end
- def self.screen_x
- return @screen_x
- end
- def self.screen_y
- return @screen_y
- end
- def self.map_id
- return @map_id
- end
- def self.map_x
- return @map_x
- end
- def self.map_y
- return @map_y
- end
- def self.direction
- return @direction
- end
- def self.icon
- return @icon
- end
- def self.town_name
- return @town_name
- end
- def self.switch
- return @switch
- end
- def self.upper_level
- return @upper_level
- end
- end
- #==============================================================================
- # ** Sprite_Cursor
- #------------------------------------------------------------------------------
- # This sprite is used to display the cursor for World_Map.
- #==============================================================================
- class Sprite_Cursor < Sprite
- def initialize(viewport = Viewport.new(0, 0, 0, 0))
- super(viewport)
- update
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- end
- end
- #==============================================================================
- # ** Window_Map
- #------------------------------------------------------------------------------
- # This window displays the name box for World_Map
- #==============================================================================
- class Window_Map < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 640, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.z = 2010
- @text = ""
- end
- def text=(text)
- if @text != text
- @text = text
- self.contents.clear
- self.contents.draw_text(0, 0, contents.width, 32, @text, 1)
- end
- end
- end
Expand to see the code.
- #==============================================================================
- # ** World_Map Script Settings
- #------------------------------------------------------------------------------
- # Script by : Plague180
- # Last Update : May 27, 2010
- # Version : 1.0
- # Contact Information : plague180(www.hbgames.org)
- # Contact Information : [email hidden]
- #------------------------------------------------------------------------------
- module Map_Items
- # All icons are to be located in your Graphics/Icon folder.
- # All maps are to be located in your Graphics/Pictures folder.
- # All Sub section maps must be named after the town that it is a subsection
- # of. E.g. if the main town is called: "Saar" then the map name must be:
- # "Saar.bmp"
- # Icon used for the players current location
- PLAYER_ICON = "player"
- # Icon used for the cursor
- CURSOR = "cursor"
- # Sound effect on move
- MOVE_SE = RPG::AudioFile.new("018-Teleport01", 80)
- # Cursor offset type:
- # 1 = Static Choices(cursor can only go where the player can move)
- # 2 = Free Choice(cursor can freely move, like a mouse)
- # 3 = Mouse(do i really need to exsplain?)
- CURSOR_TYPE = 1
- # Only for CURSOR_TYPE 2
- # Number of pixels to move per left(down) or right(up) press
- MOVE_PIXEL = 15
- # Only for CURSOR_TYPE 2
- # Number of pixels around the icon you can click
- PIXEL_OFFSET = 20
- # Name Styles:
- # 1 = Under the cursor
- # 2 = Help window on top of screen
- # 3 = None
- NAME_STYLE = 2
- # Only for type NAME_STYLE 2
- # Opacity of Name Window
- NAME_WINDOW_OPACITY = 235
- # Show player icon above town?
- SHOW_PLAYER = true
- # Number of the text color you want to use
- # Please note that you only need Window_Base(216 Colors) if you want to use a
- # non-default color(or use any other message script u want)
- TOWN_TEXT_COLOR = 211
- # Turn fog on and off
- FOG_ON = true
- # Graphic used for fog, must be in the Graphics/Fogs Folder
- FOG_GRAPHIC = "001-Fog01"
- # Fog Opacity
- FOG_OPACITY = 64
- # Fog scroll X
- FOG_SX = 1
- # Fog Scroll Y
- FOG_SY = 1
- # Fog Blending Type(1=Normal, 2=Add, 3=Subtract)
- FOG_BLEND_TYPE = 1
- end
- # Setup your towns here
- #
- # 1 = Screen X coordinate that u want the top left corner of icon to start.
- # 2 = Screen Y coordinate that u want the top left corner of icon to start.
- # 3 = Map Id player travels to when you click it.
- # 4 = Map X coordinate player travels to when you click it.
- # 5 = Map Y coordinate player travels to when you click it.
- # 6 = Direction(2 = Down, 4 = Left, 6 = Right, 8 = up)
- # 7 = Name of icon to use for town.
- # 8 = Name of town for name box or under the cursor
- # 9 = Switch used to lock and unlock that town.
- #
- # Example Map_Items::Town.new(screen_x, screen_y, map_id, map_x, map_y, direction
- # icon_name, town_name, switch)
- #
- # Sub sections are the same as normal maps, with the exception that their
- # last item is the name of the town that they are a sub section of.
- #
- # Example Sub::Town.new(screen_x, screen_y, map_id, map_x, map_y, direction
- # icon_name, town_name, switch, upper_level)
- #
- # VERY IMPORTANT: Put the towns in the order you want the game to cycle threw
- # them. you dont have to unlock them in order, just insert them in the order
- # you plan too have them cycle when they all are unlocked.
- Map_Items::Town.new(80,130,1,8,4,2,"town3","Saar",1)
- Sub::Town.new(100,80,1,3,8,2,"town3","Shop",8,"Saar")
- Sub::Town.new(380,130,1,18,5,2,"town3","Black Smith",9,"Saar")
- Sub::Town.new(330,340,1,18,14,2,"town3","Home",10,"Saar")
- Map_Items::Town.new(150,300,2,6,2,4,"snowtown","Alphian",2)
- Sub::Town.new(120,80,2,16,6,2,"town3","Store",11,"Alphian")
- Sub::Town.new(400,130,2,2,5,2,"town3","Armory",12,"Alphian")
- Sub::Town.new(350,340,2,6,14,2,"town3","House",13,"Alphian")
- Map_Items::Town.new(215,370,3,10,3,2,"mountain","Dwarven Mine",3)
- Map_Items::Town.new(270,105,4,9,4,2,"castle","Royal Palace",4)
- Map_Items::Town.new(425,340,5,10,5,6,"tower","Tower",5)
- Map_Items::Town.new(450,100,6,9,3,2,"ruins","Lost Ruins",6)
- Map_Items::Town.new(520,50,7,10,4,8,"forrest","Elven Forrest",7)
Expand to see the code.
- #==============================================================================
- # ** Interactive World Map Script
- #------------------------------------------------------------------------------
- # Script by : Plague180
- # Last Update : June 13, 2010
- # Version : 1.1
- # Contact Information : plague180(www.hbgames.org)
- # Contact Information : [email hidden]
- #------------------------------------------------------------------------------
- # * Version History :
- # May 27, 2010 - Version 1.0 Initial Release
- # June 13, 2010 - Version 1.1 Fixed Bugs with cursor type 2
- #------------------------------------------------------------------------------
- class World_Map < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(index=$game_map.map_id)
- super(0, 0, 640, 480)
- self.contents = Bitmap.new(640-32, 480-32)
- self.z = 2010
- self.opacity = 0
- @draw_player = true
- @start = index
- @pindex = first_check
- @cursor = Sprite_Cursor.new()
- @cursor.bitmap = RPG::Cache.icon(Map_Items::CURSOR)
- @cursor.z = 2020
- if Map_Items::CURSOR_TYPE == 2
- @cursor.x = Map_Items::Towns[@pindex].screen_x + RPG::Cache.icon(Map_Items::Towns[@pindex].icon).width/4
- @cursor.y = Map_Items::Towns[@pindex].screen_y + RPG::Cache.icon(Map_Items::Towns[@pindex].icon).height
- @cursor.z = 2020
- end
- if second_check != true
- @draw_player = false
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Return value of @pindex
- #--------------------------------------------------------------------------
- def pindex
- return @pindex
- end
- #--------------------------------------------------------------------------
- # * Update the value of @pindex so the name box knows what name to disply
- #--------------------------------------------------------------------------
- def update_pindex
- @cursor.x, @cursor.y = Mouse.mouse_pos
- end
- #--------------------------------------------------------------------------
- # * Set the value of @cursor.x
- #--------------------------------------------------------------------------
- def set_x(set)
- @cursor.x = set
- end
- #--------------------------------------------------------------------------
- # * Set the value of @cursor.x
- #--------------------------------------------------------------------------
- def set_y(set)
- @cursor.y = set
- end
- #--------------------------------------------------------------------------
- # * find map to start on(for cursor)
- #--------------------------------------------------------------------------
- def first_check
- for i in 1...Map_Items::Towns.size+1
- if $game_switches[Map_Items::Towns[i].switch] == true
- return i
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check to see if the player is on a valid map(inside of Map_Items::Towns)
- # (used to determin if the player is on one of the drawable maps)
- #--------------------------------------------------------------------------
- def second_check
- for i in 1...Map_Items::Towns.size+1
- if Map_Items::Towns[i].map_id == $game_map.map_id
- if $game_switches[Map_Items::Towns[i].switch] == true
- return true
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check for sub sections before moving
- #--------------------------------------------------------------------------
- def check_move(index=0)
- for i in 1...Sub::Towns.size+1
- if Map_Items::CURSOR_TYPE != 1
- if Map_Items::Towns[index].town_name == Sub::Towns[i].upper_level
- if Map_Items::CURSOR_TYPE == 2
- $scene = Scene_Sub_Map.new(Map_Items::Towns[index].town_name)
- end
- if Map_Items::CURSOR_TYPE == 3
- $scene = Scene_Sub_Map.new(Map_Items::Towns[index].town_name)
- end
- return
- end#not type 1
- end
- if Map_Items::CURSOR_TYPE == 1
- if Map_Items::Towns[@pindex].town_name == Sub::Towns[i].upper_level
- $scene = Scene_Sub_Map.new(Map_Items::Towns[@pindex].town_name)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Move Player To New Map
- #--------------------------------------------------------------------------
- def move(index=0)
- $game_system.se_play(Map_Items::MOVE_SE)
- if Map_Items::CURSOR_TYPE == 1
- index = @pindex
- end
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- $game_temp.player_new_map_id = Map_Items::Towns[index].map_id
- $game_temp.player_new_x = Map_Items::Towns[index].map_x
- $game_temp.player_new_y = Map_Items::Towns[index].map_y
- $game_temp.player_new_direction = Map_Items::Towns[index].direction
- $game_temp.player_transferring = true
- $game_map.autoplay
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # * Check if you can move(and do it if you can)
- #--------------------------------------------------------------------------
- def move_if_can
- for i in 1...Map_Items::Towns.size+1
- if @cursor.x > Map_Items::Towns[i].screen_x-Map_Items::PIXEL_OFFSET && @cursor.x < Map_Items::Towns[i].screen_x + RPG::Cache.icon(Map_Items::Towns[i].icon).width + Map_Items::PIXEL_OFFSET
- if @cursor.y > Map_Items::Towns[i].screen_y-Map_Items::PIXEL_OFFSET && @cursor.y < Map_Items::Towns[i].screen_y + RPG::Cache.icon(Map_Items::Towns[i].icon).height + Map_Items::PIXEL_OFFSET
- check_move(i)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check if you can click on town, if so show name
- #--------------------------------------------------------------------------
- def check_name
- for i in 1...Map_Items::Towns.size+1
- if @cursor.x > Map_Items::Towns[i].screen_x - Map_Items::PIXEL_OFFSET && @cursor.x < Map_Items::Towns[i].screen_x + RPG::Cache.icon(Map_Items::Towns[i].icon).width + Map_Items::PIXEL_OFFSET
- if @cursor.y > Map_Items::Towns[i].screen_y - Map_Items::PIXEL_OFFSET && @cursor.y < Map_Items::Towns[i].screen_y + RPG::Cache.icon(Map_Items::Towns[i].icon).height + Map_Items::PIXEL_OFFSET
- self.contents.clear
- refresh
- self.contents.font.size = 18
- self.contents.font.color = text_color(Map_Items::TOWN_TEXT_COLOR)
- cx = contents.text_size(Map_Items::Towns[i].town_name).width
- if $game_switches[Map_Items::Towns[i].switch] == true #unlocked?
- self.contents.draw_text(@cursor.x-cx/2,@cursor.y,cx,32,Map_Items::Towns[i].town_name)
- end
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check if you can click on town, if so show name window
- #--------------------------------------------------------------------------
- def check_name_window
- for i in 1...Map_Items::Towns.size+1
- if @cursor.x > Map_Items::Towns[i].screen_x - Map_Items::PIXEL_OFFSET && @cursor.x < Map_Items::Towns[i].screen_x + RPG::Cache.icon(Map_Items::Towns[i].icon).width + Map_Items::PIXEL_OFFSET
- if @cursor.y > Map_Items::Towns[i].screen_y-Map_Items::PIXEL_OFFSET && @cursor.y < Map_Items::Towns[i].screen_y + RPG::Cache.icon(Map_Items::Towns[i].icon).height + Map_Items::PIXEL_OFFSET
- if $game_switches[Map_Items::Towns[i].switch] == true #unlocked?
- return Map_Items::Towns[i].town_name
- end
- end
- end
- end
- return ""
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Right
- #--------------------------------------------------------------------------
- def move_cursor_right_one
- @cursor.x += Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Left
- #--------------------------------------------------------------------------
- def move_cursor_left_one
- @cursor.x -= Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Up
- #--------------------------------------------------------------------------
- def move_cursor_up_one
- @cursor.y -= Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Down
- #--------------------------------------------------------------------------
- def move_cursor_down_one
- @cursor.y += Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Right
- #--------------------------------------------------------------------------
- def move_cursor_right
- @pindex += 1
- if @pindex > Map_Items::Towns.size
- @pindex = 1
- end
- for i in 1...Map_Items::Towns.size+1
- if $game_switches[Map_Items::Towns[@pindex].switch] == false
- @pindex += 1
- if @pindex > Map_Items::Towns.size
- @pindex = 1
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Left
- #--------------------------------------------------------------------------
- def move_cursor_left
- @pindex -= 1
- if @pindex < 1
- @pindex = Map_Items::Towns.size
- end
- for i in 1...Map_Items::Towns.size+1
- if $game_switches[Map_Items::Towns[@pindex].switch] == false
- @pindex -= 1
- if @pindex < 1
- @pindex = Map_Items::Towns.size
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Up
- #--------------------------------------------------------------------------
- def move_cursor_up
- @pindex += 1
- if @pindex > Map_Items::Towns.size
- @pindex = 1
- end
- for i in 1...Map_Items::Towns.size+1
- if $game_switches[Map_Items::Towns[@pindex].switch] == false
- @pindex += 1
- if @pindex > Map_Items::Towns.size
- @pindex = 1
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Down
- #--------------------------------------------------------------------------
- def move_cursor_down
- @pindex -= 1
- if @pindex < 1
- @pindex = Map_Items::Towns.size
- end
- for i in 1...Map_Items::Towns.size+1
- if $game_switches[Map_Items::Towns[@pindex].switch] == false
- @pindex -= 1
- if @pindex < 1
- @pindex = Map_Items::Towns.size
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Draw Player
- #--------------------------------------------------------------------------
- def draw_player
- bitmap = RPG::Cache.icon(Map_Items::PLAYER_ICON)
- @player_offset_x = Map_Items::Towns[@start].screen_x - (bitmap.width / 2)
- @player_offset_y = Map_Items::Towns[@start].screen_y - bitmap.height - (RPG::Cache.icon(Map_Items::Towns[@start].icon).height / 2)
- self.contents.blt(@player_offset_x,@player_offset_y, bitmap, Rect.new(0,0,RPG::Cache.icon(Map_Items::PLAYER_ICON).height,RPG::Cache.icon(Map_Items::PLAYER_ICON).width))
- end
- #--------------------------------------------------------------------------
- # * Draw Towns
- #--------------------------------------------------------------------------
- def draw_towns
- for i in 1...Map_Items::Towns.size+1
- if $game_switches[Map_Items::Towns[i].switch] == true
- bitmap = RPG::Cache.icon(Map_Items::Towns[i].icon)
- self.contents.blt(Map_Items::Towns[i].screen_x-(bitmap.width/2), Map_Items::Towns[i].screen_y-(bitmap.height/2), bitmap, Rect.new(0,0,bitmap.width,bitmap.height))
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Cursor
- #--------------------------------------------------------------------------
- def draw_cursor
- if Map_Items::CURSOR_TYPE == 1
- bitmap = @cursor.bitmap
- # IF YOU GET ERROR ON THIS LINE YOU MOST LIKLY HAVE NO TOWNS UNLOCKED
- if $game_switches[Map_Items::Towns[@pindex].switch] == true
- if Map_Items::Towns[@pindex].icon != nil
- x = Map_Items::Towns[@pindex].screen_x - (bitmap.width / 2)
- y = Map_Items::Towns[@pindex].screen_y + (RPG::Cache.icon(Map_Items::Towns[@pindex].icon).height / 2 + 3)
- end
- if Map_Items::Towns[@pindex].icon != nil
- self.contents.blt(x, y, bitmap, Rect.new(0,0,bitmap.height,bitmap.width))
- else
- self.contents.blt(Map_Items::Towns[@pindex].screen_x, Map_Items::Towns[@pindex].screen_y+bitmap.width, bitmap, Rect.new(0,0,bitmap.height,bitmap.width))
- end
- if Map_Items::NAME_STYLE == 1
- self.contents.font.size = 18
- cx = contents.text_size(Map_Items::Towns[@pindex].town_name).width
- x = Map_Items::Towns[@pindex].screen_x+(RPG::Cache.icon(Map_Items::Towns[@pindex].icon).width/2)-cx/2
- self.contents.font.color = text_color(Map_Items::TOWN_TEXT_COLOR)
- self.contents.draw_text(x,y,cx,32,Map_Items::Towns[@pindex].town_name)
- end
- end
- end
- if Map_Items::CURSOR_TYPE == 2
- bitmap = @cursor.bitmap
- self.contents.blt(@cursor.x, @cursor.y, bitmap, Rect.new(0,0,bitmap.height,bitmap.width))
- end
- end
- #--------------------------------------------------------------------------
- # * Check cursor bounds so it doesnt go off screen
- #--------------------------------------------------------------------------
- def check_cursor_bounds
- if @cursor.x < 0
- @cursor.x = 0
- end
- if @cursor.x > 640 - RPG::Cache.icon(Map_Items::CURSOR).width - 32
- @cursor.x = 640 - RPG::Cache.icon(Map_Items::CURSOR).width - 32
- end
- if @cursor.y < 0
- @cursor.y = 0
- end
- if @cursor.y > 480 - RPG::Cache.icon(Map_Items::CURSOR).height - 32
- @cursor.y = 480 - RPG::Cache.icon(Map_Items::CURSOR).height - 32
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- check_cursor_bounds
- #draws player
- if Map_Items::SHOW_PLAYER == true
- if @draw_player == true
- draw_player
- end
- end
- #draws all towns
- draw_towns
- #draw cursor
- draw_cursor
- end
- end
Expand to see the code.
- #==============================================================================
- # ** Scene_World_Map
- #------------------------------------------------------------------------------
- # Script by : Plague180
- # Last Update : May 27, 2010
- # Version : 1.0
- # Contact Information : plague180(www.hbgames.org)
- # Contact Information : [email hidden]
- #------------------------------------------------------------------------------
- # e.g $scene = Scene_World_Map.new("World_Map.bmp")
- #------------------------------------------------------------------------------
- class Scene_World_Map
- def initialize(name)
- @name = name.to_s
- @map = Sprite.new
- @map.bitmap = RPG::Cache.picture(@name)
- @map.z = 2000
- if Map_Items::FOG_ON == true
- @fog = Plane.new
- @fog.bitmap = RPG::Cache.fog(Map_Items::FOG_GRAPHIC,0)
- @fog.opacity = Map_Items::FOG_OPACITY
- @fog.blend_type = Map_Items::FOG_BLEND_TYPE
- @fog.z = 2005
- end
- if Map_Items::CURSOR_TYPE == 3
- @mouse = Mouse_Reader.new
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Make World Map window
- @world_map = World_Map.new()
- # Make town name window
- if Map_Items::NAME_STYLE == 2
- @name_window = Window_Map.new
- @name_window.opacity = Map_Items::NAME_WINDOW_OPACITY
- @name_window.text = Map_Items::Towns[@world_map.pindex].town_name
- end
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- if Map_Items::CURSOR_TYPE == 3
- @mouse.disable
- end
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @world_map.dispose
- @map.dispose
- if Map_Items::FOG_ON == true
- @fog.dispose
- end
- if Map_Items::NAME_STYLE == 2
- @name_window.dispose
- end
- end
- def update
- # Update windows
- @world_map.update
- @map.update
- if Map_Items::CURSOR_TYPE == 3
- @mouse.update
- @world_map.update_pindex
- end
- if Map_Items::FOG_ON == true
- @fog.ox += Map_Items::FOG_SX
- @fog.oy -= Map_Items::FOG_SY
- end
- if Map_Items::NAME_STYLE == 1
- @world_map.check_name
- end
- if Map_Items::NAME_STYLE == 2
- @name_window.text = Map_Items::Towns[@world_map.pindex].town_name
- @name_window.update
- if Map_Items::CURSOR_TYPE == 2
- @name_window.text = @world_map.check_name_window
- @name_window.update
- end
- if Map_Items::CURSOR_TYPE == 3
- @name_window.text = @world_map.check_name_window
- @name_window.update
- end
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Return to map
- $scene = Scene_Map.new
- return
- end
- if Input.trigger?(Input::RIGHT)
- # Move the cursor to the right
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_right
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_right_one
- end
- return
- end
- # If L button was pressed
- if Input.trigger?(Input::LEFT)
- # Move the cursor to the left
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_left
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_left_one
- end
- return
- end
- # If Up button was pressed
- if Input.trigger?(Input::UP)
- # Move the cursor to the left
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_up
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_up_one
- end
- return
- end
- # If Down button was pressed
- if Input.trigger?(Input::DOWN)
- # Move the cursor to the left
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_down
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_down_one
- end
- return
- end
- if Input.trigger?(Input::C)
- # Switch to item screen
- if Map_Items::CURSOR_TYPE == 1
- @world_map.check_move
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_if_can
- end
- end
- if Input.triggered?(Input::Mouse_Left)
- @x, @y = Mouse.mouse_pos
- @world_map.set_x(@x)
- @world_map.set_y(@y)
- @world_map.move_if_can
- end
- end
- end
Expand to see the code.
- #==============================================================================
- # ** Sub_Map
- #------------------------------------------------------------------------------
- # Script by : Plague180
- # Last Update : June 13, 2010
- # Version : 1.0
- # Contact Information : plague180(http://www.hbgames.org)
- # Contact Information : [email hidden]
- #------------------------------------------------------------------------------
- # * Version History :
- # May 27, 2010 - Version 1.0 Initial Release
- #------------------------------------------------------------------------------
- class Sub_Map < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(upper)
- super(0, 0, 640, 480)
- self.contents = Bitmap.new(640-32, 480-32)
- self.z = 2010
- self.opacity = 0
- @section = []
- @section[0] = nil#fills spot 0 in array, to fix problem with pindex
- @upper = upper
- @draw_player = true
- @start = $game_map.map_id
- make_section
- @pindex = first_check
- @cursor = Sprite_Cursor.new()
- @cursor.bitmap = RPG::Cache.icon(Map_Items::CURSOR)
- @cursor.z = 2020
- if Map_Items::CURSOR_TYPE == 2
- @cursor.x = Sub::Towns[@pindex].screen_x + RPG::Cache.icon(Sub::Towns[@pindex].icon).width/4
- @cursor.y = Sub::Towns[@pindex].screen_y + RPG::Cache.icon(Sub::Towns[@pindex].icon).height
- @cursor.z = 2020
- end
- if second_check != true
- @draw_player = false
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Fill @section for drawing correct sub sections
- #--------------------------------------------------------------------------
- def make_section
- for i in 1...Sub::Towns.size+1
- if Sub::Towns[i].upper_level == @upper
- @section.push(Sub::Towns[i])
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Return value of @pindex
- #--------------------------------------------------------------------------
- def pindex
- return @pindex
- end
- #--------------------------------------------------------------------------
- # * Return @section for name box processing
- #--------------------------------------------------------------------------
- def section
- return @section
- end
- #--------------------------------------------------------------------------
- # * Update the value of @pindex so the name box knows what name to disply
- #--------------------------------------------------------------------------
- def update_pindex
- @cursor.x, @cursor.y = Mouse.mouse_pos
- end
- #--------------------------------------------------------------------------
- # * Set the value of @cursor.x
- #--------------------------------------------------------------------------
- def set_x(set)
- @cursor.x = set
- end
- #--------------------------------------------------------------------------
- # * Set the value of @cursor.x
- #--------------------------------------------------------------------------
- def set_y(set)
- @cursor.y = set
- end
- #--------------------------------------------------------------------------
- # * find map to start on(for cursor)
- #--------------------------------------------------------------------------
- def first_check
- for i in 1...@section.size
- if $game_switches[@section[i].switch] == true
- return (i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check to see if the player is on a valid map(inside of @section)
- #--------------------------------------------------------------------------
- def second_check
- for i in 1...@section.size
- if @section[i].map_id == $game_map.map_id
- if $game_switches[@section[i].switch] == true
- return true
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Move Player To New Map
- #--------------------------------------------------------------------------
- def move(index=0)
- $game_system.se_play(Map_Items::MOVE_SE)
- if Map_Items::CURSOR_TYPE == 1
- index = @pindex
- end
- Audio.bgm_fade(800)
- Audio.bgs_fade(800)
- Audio.me_fade(800)
- $game_temp.player_new_map_id = @section[index].map_id
- $game_temp.player_new_x = @section[index].map_x
- $game_temp.player_new_y = @section[index].map_y
- $game_temp.player_new_direction = @section[index].direction
- $game_temp.player_transferring = true
- $game_map.autoplay
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # * Check if can move(and do it if you can)
- #--------------------------------------------------------------------------
- def move_if_can
- for i in 1...@section.size
- if @cursor.x > @section[i].screen_x-Map_Items::PIXEL_OFFSET && @cursor.x < @section[i].screen_x + RPG::Cache.icon(@section[i].icon).width + Map_Items::PIXEL_OFFSET
- if @cursor.y > @section[i].screen_y-Map_Items::PIXEL_OFFSET && @cursor.y < @section[i].screen_y + RPG::Cache.icon(@section[i].icon).height + Map_Items::PIXEL_OFFSET
- move(i)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check if you can click on town, if so show name
- #--------------------------------------------------------------------------
- def check_name
- for i in 1...@section.size
- if @cursor.x > @section[i].screen_x - Map_Items::PIXEL_OFFSET && @cursor.x < @section[i].screen_x + RPG::Cache.icon(@section[i].icon).width + Map_Items::PIXEL_OFFSET
- if @cursor.y > @section[i].screen_y - Map_Items::PIXEL_OFFSET && @cursor.y < @section[i].screen_y + RPG::Cache.icon(@section[i].icon).height + Map_Items::PIXEL_OFFSET
- self.contents.clear
- refresh
- self.contents.font.size = 18
- self.contents.font.color = text_color(Map_Items::TOWN_TEXT_COLOR)
- cx = contents.text_size(@section[i].town_name).width
- if $game_switches[@section[i].switch] == true #unlocked?
- self.contents.draw_text(@cursor.x-cx/2,@cursor.y,cx,32,@section[i].town_name)
- end
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Check if you can click on town, if so show name window
- #--------------------------------------------------------------------------
- def check_name_window
- for i in 1...@section.size
- if @cursor.x > @section[i].screen_x - Map_Items::PIXEL_OFFSET && @cursor.x < @section[i].screen_x + RPG::Cache.icon(@section[i].icon).width + Map_Items::PIXEL_OFFSET
- if @cursor.y > @section[i].screen_y-Map_Items::PIXEL_OFFSET && @cursor.y < @section[i].screen_y + RPG::Cache.icon(@section[i].icon).height + Map_Items::PIXEL_OFFSET
- if $game_switches[@section[i].switch] == true #unlocked?
- return @section[i].town_name
- end
- end
- end
- end
- return ""
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Right
- #--------------------------------------------------------------------------
- def move_cursor_right_one
- @cursor.x += Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Left
- #--------------------------------------------------------------------------
- def move_cursor_left_one
- @cursor.x -= Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Up
- #--------------------------------------------------------------------------
- def move_cursor_up_one
- @cursor.y -= Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Down
- #--------------------------------------------------------------------------
- def move_cursor_down_one
- @cursor.y += Map_Items::MOVE_PIXEL
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Right
- #--------------------------------------------------------------------------
- def move_cursor_right
- @pindex += 1
- if @pindex > @section.size-1
- @pindex = 1
- end
- for i in 1...@section.size
- if $game_switches[@section[@pindex].switch] == false
- @pindex += 1
- if @pindex > @section.size-1
- @pindex = 1
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Left
- #--------------------------------------------------------------------------
- def move_cursor_left
- @pindex -= 1
- if @pindex < 1
- @pindex = @section.size-1
- end
- for i in 1...@section.size
- if $game_switches[@section[@pindex].switch] == false
- @pindex -= 1
- if @pindex < 1
- @pindex = @section.size-1
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Up
- #--------------------------------------------------------------------------
- def move_cursor_up
- @pindex += 1
- if @pindex > @section.size-1
- @pindex = 1
- end
- for i in 1...@section.size
- if $game_switches[@section[@pindex].switch] == false
- @pindex += 1
- if @pindex > @section.size-1
- @pindex = 1
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Down
- #--------------------------------------------------------------------------
- def move_cursor_down
- @pindex -= 1
- if @pindex < 1
- @pindex = @section.size-1
- end
- for i in 1...@section.size
- if $game_switches[@section[@pindex].switch] == false
- @pindex -= 1
- if @pindex < 1
- @pindex = @section.size-1
- end
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # * Draw Player
- #--------------------------------------------------------------------------
- def draw_player
- bitmap = RPG::Cache.icon(Map_Items::PLAYER_ICON)
- @player_offset_x = @section[@start].screen_x - (bitmap.width / 2)
- @player_offset_y = @section[@start].screen_y - bitmap.height - (RPG::Cache.icon(@section[@start].icon).height / 2)
- self.contents.blt(@player_offset_x,@player_offset_y, bitmap, Rect.new(0,0,RPG::Cache.icon(Map_Items::PLAYER_ICON).height,RPG::Cache.icon(Map_Items::PLAYER_ICON).width))
- end
- #--------------------------------------------------------------------------
- # * Draw Towns
- #--------------------------------------------------------------------------
- def draw_towns
- for i in 1...@section.size
- if $game_switches[@section[i].switch] == true #unlocked?
- bitmap = RPG::Cache.icon(@section[i].icon)
- self.contents.blt(@section[i].screen_x-(bitmap.width/2), @section[i].screen_y-(bitmap.height/2), bitmap, Rect.new(0,0,bitmap.width,bitmap.height))
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Cursor
- #--------------------------------------------------------------------------
- def draw_cursor
- if Map_Items::CURSOR_TYPE == 1
- bitmap = @cursor.bitmap
- # IF YOU GET ERROR ON THIS LINE YOU MOST LIKLY HAVE NO sub sections UNLOCKED
- if $game_switches[@section[@pindex].switch] == true
- if @section[@pindex].icon != nil
- x = @section[@pindex].screen_x - (bitmap.width / 2)
- y = @section[@pindex].screen_y + (RPG::Cache.icon(@section[@pindex].icon).height / 2 + 3)
- end
- if @section[@pindex].icon != nil
- self.contents.blt(x, y, bitmap, Rect.new(0,0,bitmap.height,bitmap.width))
- else
- self.contents.blt(@section[@pindex].screen_x, @section[@pindex].screen_y+bitmap.width, bitmap, Rect.new(0,0,bitmap.height,bitmap.width))
- end
- if Map_Items::NAME_STYLE == 1
- self.contents.font.size = 18
- cx = contents.text_size(@section[@pindex].town_name).width
- x = @section[@pindex].screen_x+(RPG::Cache.icon(@section[@pindex].icon).width/2)-cx/2
- self.contents.font.color = text_color(Map_Items::TOWN_TEXT_COLOR)
- self.contents.draw_text(x,y,cx,32,@section[@pindex].town_name)
- end
- end
- end
- if Map_Items::CURSOR_TYPE == 2
- bitmap = @cursor.bitmap
- self.contents.blt(@cursor.x, @cursor.y, bitmap, Rect.new(0,0,bitmap.height,bitmap.width))
- end
- end
- #--------------------------------------------------------------------------
- # * Check cursor bounds so it doesnt go off screen
- #--------------------------------------------------------------------------
- def check_cursor_bounds
- @cursor.x = [[@cursor.x, 0].max, 640].min
- @cursor.y = [[@cursor.y, 0].max, 480].min
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- check_cursor_bounds
- #draws player
- if Map_Items::SHOW_PLAYER == true
- if @draw_player == true
- draw_player
- end
- end
- #draws all towns
- draw_towns
- #draw cursor
- draw_cursor
- end
- end #class
Expand to see the code.
- #==============================================================================
- # ** Scene_Sub_Map
- #------------------------------------------------------------------------------
- # Script by : Plague180
- # Last Update : May 27, 2010
- # Version : 1.0
- # Contact Information : plague180(www.hbgames.org)
- # Contact Information : [email hidden]
- #------------------------------------------------------------------------------
- # e.g $scene = Scene_Sub_Map.new("Saar.bmp")
- class Scene_Sub_Map
- def initialize(name)
- @name = name.to_s
- @map = Sprite.new
- @map.bitmap = RPG::Cache.picture(@name)
- @map.z = 2000
- if Map_Items::CURSOR_TYPE == 3
- @mouse = Mouse_Reader.new
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Make world Map window
- @world_map = Sub_Map.new(@name)
- # Make town name window
- if Map_Items::NAME_STYLE == 2
- @name_window = Window_Map.new
- @name_window.opacity = Map_Items::NAME_WINDOW_OPACITY
- @section = @world_map.section
- @name_window.text = @section[@world_map.pindex].town_name
- end
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if screen is changed
- if $scene != self
- if Map_Items::CURSOR_TYPE == 3
- @mouse.disable
- end
- break
- end
- end
- # Prepare for transition
- Graphics.freeze
- # Dispose of windows
- @world_map.dispose
- @map.dispose
- if Map_Items::NAME_STYLE == 2
- @name_window.dispose
- end
- end
- def update
- # Update windows
- @world_map.update
- @map.update
- if Map_Items::CURSOR_TYPE == 3
- @mouse.update
- @world_map.update_pindex
- end
- if Map_Items::NAME_STYLE == 1
- @world_map.check_name
- end
- if Map_Items::NAME_STYLE == 2
- @name_window.text = @section[@world_map.pindex].town_name
- @name_window.update
- if Map_Items::CURSOR_TYPE == 2
- @name_window.text = @world_map.check_name_window
- @name_window.update
- end
- if Map_Items::CURSOR_TYPE == 3
- @name_window.text = @world_map.check_name_window
- @name_window.update
- end
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Return to map
- $scene = Scene_Map.new
- return
- end
- if Input.trigger?(Input::RIGHT)
- # Move the cursor to the right
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_right
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_right_one
- end
- return
- end
- # If L button was pressed
- if Input.trigger?(Input::LEFT)
- # Move the cursor to the left
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_left
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_left_one
- end
- return
- end
- # If Up button was pressed
- if Input.trigger?(Input::UP)
- # Move the cursor to the left
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_up
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_up_one
- end
- return
- end
- # If Down button was pressed
- if Input.trigger?(Input::DOWN)
- # Move the cursor to the left
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move_cursor_down
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_cursor_down_one
- end
- return
- end
- if Input.trigger?(Input::C)
- # Switch to item screen
- if Map_Items::CURSOR_TYPE == 1
- @world_map.move
- end
- if Map_Items::CURSOR_TYPE == 2
- @world_map.move_if_can
- end
- end
- if Input.triggered?(Input::Mouse_Left)
- @x, @y = Mouse.mouse_pos
- @world_map.set_x(@x)
- @world_map.set_y(@y)
- @world_map.move_if_can
- end
- end
- end
Expand to see the code.
Instructions
Content Hidden
Spoiler
1 = Screen X coordinate that u want the top left corner of icon to start.
2 = Screen Y coordinate that u want the top left corner of icon to start.
3 = Map Id player travels to when you click it.
4 = Map X coordinate player travels to when you click it.
5 = Map Y coordinate player travels to when you click it.
6 = Direction(2 = Down, 4 = Left, 6 = Right, 8 = up)
7 = Name of icon to use for town.
8 = Name of town for name box or under the cursor
9 = Switch used to lock and unlock that town.
Example Map_Items::Town.new(screen_x, screen_y, map_id, map_x, map_y, direction
icon_name, town_name, switch)
Sub sections are the same as normal maps, with the exception that their
last item is the name of the town that they are a sub section of.
Example Sub::Town.new(screen_x, screen_y, map_id, map_x, map_y, direction
icon_name, town_name, switch, upper_level)
VERY IMPORTANT: Put the towns in the order you want the game to cycle threw
them. you dont have to unlock them in order, just insert them in the order
you plan too have them cycle when they all are unlocked.
2 = Screen Y coordinate that u want the top left corner of icon to start.
3 = Map Id player travels to when you click it.
4 = Map X coordinate player travels to when you click it.
5 = Map Y coordinate player travels to when you click it.
6 = Direction(2 = Down, 4 = Left, 6 = Right, 8 = up)
7 = Name of icon to use for town.
8 = Name of town for name box or under the cursor
9 = Switch used to lock and unlock that town.
Example Map_Items::Town.new(screen_x, screen_y, map_id, map_x, map_y, direction
icon_name, town_name, switch)
Sub sections are the same as normal maps, with the exception that their
last item is the name of the town that they are a sub section of.
Example Sub::Town.new(screen_x, screen_y, map_id, map_x, map_y, direction
icon_name, town_name, switch, upper_level)
VERY IMPORTANT: Put the towns in the order you want the game to cycle threw
them. you dont have to unlock them in order, just insert them in the order
you plan too have them cycle when they all are unlocked.
FAQ
Q: I get an error on line 305 in world_map, what wrong?
A: You don't have any towns UNLOCKED yet.
Q:I get an error on line 299 in sub_map, what wrong?
A: You don't have any sub sections for that town unlocked UNLOCKED. Shouldn't ever have an issue here because if there is no subsection it is sapose to go straight to the default, but one person did get this error.
Compatibility
Haven't tested it with anything out side of my other custom scripts, but if you have a mouse system it might clash with this(if u use my mouse, but if u dont then it might not accept your clicks)
Credits and Thanks
SephirothSpawn - Created Data Structure
CyberSam - Keyboard Input Module
CyberSam - Mouse Module
Mr.Mo - Error Log
Tomas - World Map Background
Special Thanks to Silver Wind for all his help with my Sub Sections
Special Thanks to SephirothSpawn for all his support coding and moral, Thanks man!
Author's Notes
I work alot, but i will help you with any problems asap.
if you have a game that uses my script i would love to see what my script can do with good graphics :)
Terms and Conditions
I do not what this script hosted anywhere other then http://www.hbgames.org with out my permission. free for use commercial and noncommercial.