12-26-2006, 01:00 PM
Map Item
by daniel_maximus2
Dec 26 2006
This is my first Script! after a month studying I started making this simple, but functional and efficient map item.
You need:
* A map of 640x380
* A compass of 60x60 (different sizes changes lines 81 and 82)
* A picture of 640x3 (line y)
* A picture of 3x380 (line x)
The pictures must be placed in Pictures/Mapa
Install:
Put the code above main.
Now in Scene_Item
add in def update_item
below:
this
Maps:
Map and compass:
Function:
* create the map item and the compass item and put the ID in the Script. These items do nothing, as the commands are in Scene_Item (They are not common event, like in rmk2).
* in each map of RMXP make a paralell process event that defines values for a variable x and a variable y (the ID of the variable must be put in the script, changing the constants VAR_MAP_X e VAR_MAP_Y).
* the constants WORLDCERTERX e WORLDCENTERY are the world center point. If you don´t want a center, the written location will be wrong...
* If you don´t know the cordinates of cities and places, open your map in paint and put the mouse pointer above the point of the place. right in the screen, will be shown the screen cordinate. Now go to the event and define these values in the variables you created and the compass will be moved to this cordinate.
Obs.: PLEASE! do not use the maps in the Screenshots in your games (If you want I can help to make a map picture, since I have free time...).
Goodby!!!!!!!!!!!!!!!!!!!!!!!!
by daniel_maximus2
Dec 26 2006
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
This is my first Script! after a month studying I started making this simple, but functional and efficient map item.
You need:
* A map of 640x380
* A compass of 60x60 (different sizes changes lines 81 and 82)
* A picture of 640x3 (line y)
* A picture of 3x380 (line x)
The pictures must be placed in Pictures/Mapa
Install:
Put the code above main.
Code:
#===============================================================================
#-------------------------------------------------------------------------------
# - Map Item Script
#-------------------------------------------------------------------------------
#===============================================================================
#
# - Shows a map and compass in the screen
# - Made by - Daniel_Maximus2
# Cardinalis Corp (R)
# - Script free for personal use since included the name and the team
# of the creator
# - Compatibility with many Scripts. See instructions for more information
#
# - Put the pictures in the folder Graphics/Pictures/Mapa (create the folder Mapa)
# - A map of 640x380
# - A compass of 60x60 (different sizes changes lines 81 and 82)
# - A picture of 640x3 (linha y)
# - A picture of 3x380 (linha x)
# - Created in 12-14-06
#
# classes: Window_Mapa
# Window_Text
# Scene_Mapa
#
#-------------------------------------------------------------------------------
#===============================================================================
COMPASS = 24 #id of Compass
MAP = 23 #id of Map
VAR_MAP_X = 2 #$game_variable[id] that stores X cordinate
VAR_MAP_Y= 3 #$game_variable[id] that stores Y cordinate
WORLDCENTERX = 240 #World center X (Optional)
WORLDCENTERY = 300 #World center Y (Optional)
# If you do not define a cordinate for center of the world, delete lines 142
# to 172 and activate lines 173 e 174.
#===============================================================================
#-------------------------------------------------------------------------------
# - Window_Mapa
#-------------------------------------------------------------------------------
#===============================================================================
class Window_Mapa < Window_Base
def initialize
super(0, 65, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
refresh
end
def refresh
# variables that stores cordinates (Events/Paralell Process)
@wx = $game_variables[VAR_MAP_X]
@wy = $game_variables[VAR_MAP_Y]
@f_linex = @wx #cord x
@f_liney = @wy #cord y
# Draw the map ========================================================
@map = Sprite.new
@map.bitmap = RPG::Cache.picture("Mapa/worldmap.jpg")#Name of map file
@map.x = 0
@map.y = 65
# Draw the map ========================================================
# Draw the compass, if have ========================================
if $game_party.item_number(COMPASS) > 0
@i_linex = Sprite.new
@i_linex.bitmap = RPG::Cache.picture("Mapa/compasso_x.png")#Name of line x file
@i_linex.x = @map.x
@i_linex.y = @map.y
@i_liney = Sprite.new
@i_liney.bitmap = RPG::Cache.picture("Mapa/compasso_y.png")#Name of line y file
@i_liney.x = @map.x
@i_liney.y = @map.y
@compass = Sprite.new
@compass.bitmap = RPG::Cache.picture("Mapa/compasso.png")#Name of compass file
@cwid = 30 #half of compass width
@chei = 30 #half of compass height
@compass.x = @map.x - @cwid
@compass.y = @map.y - @chei
end
end
# Fim ======================================================================
def move_compass
correctx = @f_linex - @i_linex.x
correcty = @f_liney - @i_liney.y
correctcompx = @wx - @cwid - @compass.x
correctcompy = @wy - @chei - @compass.y
#====================
if @i_linex.x < (@f_linex - 10)
@i_linex.x += 10
end
if @i_linex.x >= (@f_linex - 10)
@i_linex.x += correctx
end
#====================
if @i_liney.y < (@f_liney - 10)
@i_liney.y += 10
end
if @i_liney.y >= (@f_liney - 10)
@i_liney.y += correcty
end
#====================
if @compass.x < (@wx - 10 - @cwid)
@compass.x += 10
end
if @compass.x >= (@wx - 10 - @cwid)
@compass.x += correctcompx
end
#====================
if @compass.y < (@wy - 10 - @chei)
@compass.y += 10
end
if @compass.y >= (@wy - 10 - @chei)
@compass.y += correctcompy
end
#====================
end
end
#===============================================================================
#-------------------------------------------------------------------------------
# - Mapa_Text - Write the location
#-------------------------------------------------------------------------------
#===============================================================================
class Game_Map
def name
$map_infos[@map_id]
end
end
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
class Mapa_Text < Window_Base
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 200#
refresh
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = $fontsize
# delete below if you don´t use a WORLDCENTER
actualx = $game_variables[VAR_MAP_X] #character x pos
actualy = $game_variables[VAR_MAP_Y] #character y pos
centerx = WORLDCENTERX #world center x pos
centery = WORLDCENTERY #world center y pos
x = (actualx - centerx) * 2
y = (actualy - centery) * 2
centerdist = Math.sqrt(x ** 2 + y ** 2)
if x < 0
dir_x = "West"
else x > 0
dir_x = "East"
end
if y < 0
dir_y = "North"
else y > 0
dir_y = "South"
end
if x == 0
dir_x = "Center"
end
if y == 0
dir_y = "Center"
end
if $game_party.item_number(COMPASS) > 0
text = "Your location: #{$game_map.name}: #{y} Km #{dir_y}, #{x} Km #{dir_x}." #{centerdist} km de (Name of world center place or city)." Put the name of center place
else
text = "Your location: #{$game_map.name}."
end
self.contents.draw_text(4, 0, self.width - 40, 32, text)
# delete till here and activate below (delete "#")
# text = "Your location: #{$game_map.name}."
# self.contents.draw_text(4, 0, self.width - 40, 32, text)
end
end
#===============================================================================
#-------------------------------------------------------------------------------
# - Scene_Mapa
#-------------------------------------------------------------------------------
#===============================================================================
class Scene_Mapa
def main
@help_window = Mapa_Text.new
@mapa_window = Window_Mapa.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $game_party.item_number(COMPASS) > 0
@mapa_window.move_compass
end
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@mapa_window.dispose
end
#-------------------------------------------------------------------------------
# - Update
#-------------------------------------------------------------------------------
def update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(0)
return
end
end
end
Now in Scene_Item
add in def update_item
below:
Code:
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
$scene = Scene_Map.new
return
end
this
Code:
#use map==========
if @item.id == MAP
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
$scene = Scene_Mapa.new
return
end
#use map==========
Maps:
Map and compass:
Function:
* create the map item and the compass item and put the ID in the Script. These items do nothing, as the commands are in Scene_Item (They are not common event, like in rmk2).
* in each map of RMXP make a paralell process event that defines values for a variable x and a variable y (the ID of the variable must be put in the script, changing the constants VAR_MAP_X e VAR_MAP_Y).
* the constants WORLDCERTERX e WORLDCENTERY are the world center point. If you don´t want a center, the written location will be wrong...
* If you don´t know the cordinates of cities and places, open your map in paint and put the mouse pointer above the point of the place. right in the screen, will be shown the screen cordinate. Now go to the event and define these values in the variables you created and the compass will be moved to this cordinate.
Obs.: PLEASE! do not use the maps in the Screenshots in your games (If you want I can help to make a map picture, since I have free time...).
Goodby!!!!!!!!!!!!!!!!!!!!!!!!