collapse collapse

 Community


 User Info




Willkommen Gast. Bitte einloggen oder registrieren.

 Partnerseiten

rpgvx.net

Das Forum ist offline

Autor Thema: Overlord_Dave's World Map Koordinaten stimmen nicht überein  (Gelesen 673 mal)

Offline Blackstarwolf

  • Chaosbloodwolf
  • RTP-Mapper
  • *
  • Beiträge: 47
  • Ha, ich bin persönlich genug xD
    • Blackwolfgames
Overlord_Dave's World Map Koordinaten stimmen nicht überein
« am: November 24, 2011, 15:02:31 »
Hallo zusammen und ich hoffe es gut erklären zu können.

Das Skript setzt Punkte zum reisen auf einem Bild und benutzt dazu Koordinaten.
Diese lese ich mit GIMP aus.

Soweit sogut, aber jetzt kommt das Problem, wenn ich diese so einsetze sind diese versetzt und nicht dort wo sie eigentlich sein sollten.

Z.B. 140,332 setzt das Skript irgendwo bei 149,341

Warum zum Henker macht es das?
Wer findet den hoffentlich simplen Fehler x.x?

Hier mal das Skript:
   

Spoiler for Hiden:
module Overlord_Daves_WorldMap_Settings
  # ----------------------------------------------------------------------------
  # ----------------------------- Display Settings -----------------------------
  # ----------------------------------------------------------------------------
 
  # map image name (must be the Graphics/Pictures folder)
  MAP_NAME = "Karte"
 
  # whether to show the location name on the map.
  # To improve frame-rate this should generally not be set to true if GLIDE
  # is true (see Movement Settings)
  SHOW_TEXT = false
 
  # text color of the location name (as used in Window_Base.text_color)
  TEXT_COLOUR = 1
 
  # the font of the text (must be included in a Font folder or no text will be
  # displayed).  Set it to -1 to use the project's default font (as defined in
  # main).
  TEXT_FONT = -1
 
  # text size (again use -1 for project default)
  TEXT_SIZE = 20
 
  # prefix and suffix to show in the list window for the player's current
  # location.  One or both can be blank (ie. = "")
  PREFIX = " > "
  SUFFIX = " < "
 
  # icons to show when de-selected and selected (in that order)
  # set the first value to -1 if you want a 'greyed-out' version of the selected
  # icon to be used when deselected.  If you don't want the icon to change
  # simply make these both the same icon.
  LOCATION_ICONS = [97, 99]
 
  # whether custom icons are to be used
  # if no custom icon is defined (ie. set to nil) then the icons defined above
  # will be used
  CUSTOM_ICONS = false
 
  # what icon to show at the player's current location. It follows the same
  # rules as LOCATION_ICON.  If you don't want to show a different icon set the
  # 2nd value to -1.
  CURRENT_ICONS = [101, 101]
 
  # ----------------------------------------------------------------------------
  # ----------------------------- Movement Settings ----------------------------
  # ----------------------------------------------------------------------------
 
  # Note that most of these values are optimised as best I can, but they can be
  # changed as you wish.
 
  # whether the map glides or jumps to the next location
  GLIDE = true
 
  # time taken for map to move from one location to the next in frames (at 60fps)
  # a value of under 60 is recommended
  SWITCH_TIME = 30
 
  # minimum smoothness (frames between each movement)
  SMOOTHNESS = 3
 
  # motion blur settings.  I'm the first to admit that it is a bit crummy,
  # but maybe with more time to tweak these values you can get a nice effect.
  # In order the values are:
  #  - whether motion blur is on or not (true or false)
  #  - number of blured images (greater than zero)
  #  - gap in pixels between each image (set it as -1 to match velocity),
  #  - transparency of the blured images (bewteen 0 and 255)]
  BLUR = [false, 2, 5, 160]
 
end
 
# ---------------------------- CUSTOMISATION ENDS! -----------------------------
# (but the rest is well commented for all you budding scripters out there :D)
 
# ------------------------------------------------------------------------------
# --------------------------------- Overrides ----------------------------------
# ------------------------------------------------------------------------------
 
class Scene_Title < Scene_Base
  alias :ye_olde_create_objects_OvelordDave :create_game_objects
 
  def create_game_objects
ye_olde_create_objects_OvelordDave
 
# the hash to contain all the Location objects
$map_locations = {}
  end
end
 
# making it so location objects are saved and loaded
class Scene_File < Scene_Base
  alias :ye_olde_write_data_OvelordDave :write_save_data
 
  def write_save_data(file)
ye_olde_write_data_OvelordDave(file)
 
Marshal.dump($map_locations, file)
  end
 
  alias :ye_olde_read_data_OvelordDave :read_save_data
 
  def read_save_data(file)
ye_olde_read_data_OvelordDave(file)
 
$map_locations = Marshal.load(file)
  end
end
 
# ------------------------------------------------------------------------------
# ------------------------------- Scene Script ---------------------------------
# ------------------------------------------------------------------------------
 
class Overlord_Daves_WorldMap < Scene_Base
  include Overlord_Daves_WorldMap_Settings
 
  def initialize(current_map_id = $game_map.map_id, called_from = 0)
super()
 
@prev_map = current_map_id
@called_from = called_from
 
# building known locations... only add a location if it's known
@known_locations = []
for i in 0..$map_locations.size-1
  @known_locations.push($map_locations[i]) unless !$map_locations[i].known
end
 
# sort by height (north to south)
@known_locations.sort! { |a, b| a.icon_y <=> b.icon_y}
 
@map = Window_Base.new(50, 50, 50, 50)
@map_image = Cache.picture(MAP_NAME)
 
# velocity variables (explained in find_v_array)
@velocity_x = [0, 1, 0]
@velocity_y = [0, 1, 0]
 
# counter for keeping track of movement time
@counter = 0
 
update_map_window(true)
setup_list_window
  end
 
  def setup_list_window
# build locations names for list window
@l_names = []
start_index = 0
@previous_index = 0 # must be the same as start_index
 
for i in 0..@known_locations.size-1
  if @known_locations[i].map_id == @prev_map
    # start the cursor on the current map
    start_index = i
    @previous_index = i
    @l_names.push(PREFIX+@known_locations[i].name+SUFFIX)
  else
    # if the current map is not in known_locations (ie is unknown) then
    # write the name normally. the cursor will appear at start_index defined
    # before this 'for' statement
    @l_names.push(@known_locations[i].name)
  end
end
 
@list_window = Window_Command.new(200, @l_names, column_max = 1, row_max = 0, spacing = 32)
@list_window.x=344
@list_window.height = 416
@list_window.index = start_index
@list_window.back_opacity = 255
  end 
 
  def update_map_window(first_time = false)
# only create the map window once, as it's position is variable
# the contents does change however
unless first_time == false
  @map.dispose
  # map is positioned at (-32, -32) as the bitmap is offset by a border
  # of 32 pixels, and this is needed to the image to start at (0, 0)
  @map = Window_Base.new(-32,-32,@map_image.width + 64, @map_image.height + 64)
  @map.z = -10
  @map.contents.dispose
  @map.contents = Bitmap.new(@map.width-32, @map.height-32)
  @map.contents.blt(0, 0, @map_image, Rect.new(0, 0, @map_image.width, @map_image.height))
  @map.viewport = Viewport.new(0, 0, 344, 416)
end
 
c = @map.contents
 
# draw icons
for i in 0..@known_locations.size-1
  if first_time == false
    @selected_location = @known_locations[i] unless i != @list_window.index
  else
    if @known_locations[i].map_id == @prev_map
      @selected_location = @known_locations[i]
 
      # center map
      @map.x = 172 - 32 - [[@selected_location.icon_x, 172].max, @map_image.width-172-16].min
      @map.y = 208 - 32 - [[@selected_location.icon_y, 208].max, @map_image.height-208-16].min
    end
  end
 
  # in this case x & y translate directly to icon_x and y
  x = @known_locations[i].icon_x
  y = @known_locations[i].icon_y
 
  draw_map_icon(x, y, @known_locations[i])
end
  end
 
  def calculate_velocity
# find target position
# the min and max are to ensure the window stops before the map image ends
@target_x = [[@selected_location.icon_x, 172].max, @map_image.width-172-16].min
@target_y = [[@selected_location.icon_y, 208].max, @map_image.height-208-16].min
 
# find current position of center
# based on the viewport being 344x416 big, and the image's position being
# offset by 32 pixels (so when the map is in the top left it's x and y
# are -32)
current_x = 172 - 32 - @map.x
current_y = 208 - 32 - @map.y
 
# reset counter and calculate distances
@counter = SWITCH_TIME
total_x_distance = @target_x - current_x
total_y_distance = @target_y - current_y
 
@velocity_x = find_v_array(total_x_distance, @counter)
@velocity_y = find_v_array(total_y_distance, @counter)
 
  end
 
  def find_v_array(distance, time)
# velocites are an array in the form
# [speed, move frequency, counter]
# eg. 0.4 pixels per frame would correspond to v = [2, 5, 0]
# v[2] is incremented and then compared to v[1]
# if equal, the map is moved -v[0] and v[2] is set back to zero
 
# return if no movement required
if distance == 0
  return [0, 1, 0]
end
 
d1 = distance
d2 = distance
 
until d1 == 0
  # first get raw velocity
  raw1 = d1.to_f/time.to_f
 
  # return immediately if raw is a whole number
  if raw1 % 1 == 0
    return [raw1, 1, 0]
  end
 
  # round to increase chance of finding a factor
  raw1 = (raw1*10).round/10.0
 
  # in which case find what factor makes it whole
  for num in 1..SMOOTHNESS
    if (raw1*num) % 1 == 0
      return [(raw1*num), num, 0]
    end
  end
 
  # try again with second distance...
  raw2 = d2.to_f/time.to_f
  if raw2 % 1 == 0
    return [raw2, 1, 0]
  end
  raw2 = (raw2*10).round/10.0
  for num in 1..SMOOTHNESS
    if (raw2*num) % 1 == 0
      return [(raw2*num), num, 0]
    end
  end
 
  # if neither work, change distances and try again
  d1 -= 1
  d2 += 1
end
 
# if there is no factor less than SMOOTHNESS
# epic fail - sorry
p = "Error calculating v-array:\n"
p += "Raw velocity: "+raw.to_s+"\n"
p += "Switch time: "+SWITCH_TIME.to_s
print p
 
  end
 
  def refresh_window_position
if GLIDE
  # moving map...
 
  @velocity_x[2] += 1 # incrementing the counter of the velocity-array
  if @velocity_x[2] == @velocity_x[1]
    # if it's equal to the frequency move the map
    @map.x -= @velocity_x[0]
    @velocity_x[2] = 0
  end
 
  # again for y-coordinates
  @velocity_y[2] += 1
  if @velocity_y[2] == @velocity_y[1]
    @map.y -= @velocity_y[0]
    @velocity_y[2] = 0
  end
 
  # decrement the main counter
  @counter -= 1
 
  # clear contents and draw normal background
  @map.contents.clear
  @map.contents.blt(0, 0, @map_image, Rect.new(0, 0, @map_image.width, @map_image.height), 255)
 
  # must be initialised, even though if motion blur is off it will
  # never be read.
  gap = [0, 0]
 
  # motion blur
  if BLUR[0] && @velocity_x[0] != 0 && @velocity_y[0] != 0
    # find gaps (x & y) between images
    if BLUR[2] == -1
      gap = [@velocity_x[0], @velocity_y[0]]
    else
      # the velocity[0]/velocity[0].abs returns -1 or 1, ensuring
      # the gap is in the correct direction
      x = BLUR[2]*(@velocity_x[0]/@velocity_x[0].abs)
      y = BLUR[2]*(@velocity_y[0]/@velocity_y[0].abs)
      gap = [x, y]
    end
 
    # draw blured background(s)
    for i in 1..BLUR[1]
      @map.contents.blt(gap[0]*i, gap[1]*i, @map_image, Rect.new(0, 0, @map_image.width, @map_image.height), BLUR[3])
    end
  end
 
  # redraw icons
  for l in @known_locations
    if @velocity_x == 0
      x = l.icon_x
    else
      # compensates for an offset when bluring.
      # I'm not entirely sure why this is necessary, but a future
      # release might solve the problem
      x = BLUR[0] ? (l.icon_x+gap[0]*BLUR[1]) : l.icon_x
    end
 
    if @velocity_y == 0
      y = l.icon_y
    else
      y = BLUR[0] ? (l.icon_y+gap[1]*BLUR[1]) : l.icon_y
    end
 
    draw_map_icon(x, y, l)
  end
 
  # set map to final position when counter is at 1
  if @counter == 1
    @map.x = 172 - 32 - @target_x
    @map.y = 208 - 32 - @target_y
 
    # reseting...
    @counter = 0
    @velocity_x = [0, 1, 0]
    @velocity_y = [0, 1, 0]
  end
else # GLIDE is set to false
 
  # jump straight to the target position
  @target_x = [[@selected_location.icon_x, 172].max, @map_image.width-172-16].min
  @target_y = [[@selected_location.icon_y, 208].max, @map_image.height-208-16].min
 
  @map.x = 172 - 32 - @target_x
  @map.y = 208 - 32 - @target_y
 
  @map.contents.clear
  @map.contents.blt(0, 0, @map_image, Rect.new(0, 0, @map_image.width, @map_image.height), 255)
 
  for l in @known_locations
    draw_map_icon(l.icon_x, l.icon_y, l)
  end
end
 
  end
 
  def update
super
 
# define targeteted location
for i in 0..@known_locations.size-1
  if i == @list_window.index
    @selected_location = @known_locations[i]
  end
end
 
# if the target location has changed, recalculate velocities
if @previous_index != @list_window.index
  update_map_window
 
  # no point calculating velocities if GLIDE is false
  calculate_velocity unless !GLIDE
 
  @previous_index = @list_window.index
end
 
if Input.trigger?(Input::C)
  i = @list_window.index
  if @known_locations[i].map_id == @prev_map
    # if the selected location is map the player is on
    Sound.play_cancel
 
    # find the opposite direction
    opp_direction = case $game_player.direction
      when 2: 8 # down -> up
      when 4: 6 # left -> right
      when 6: 4 # right -> left
      when 8: 2 # up -> down
    end
 
    # turn the player round and exit
    player_transition(@prev_map,
                      $game_player.x,
                      $game_player.y,
                      opp_direction)
  else
    # put the player in the new map
    Sound.play_decision
    player_transition(@known_locations[i].map_id,
                      @known_locations[i].entry_x,
                      @known_locations[i].entry_y,
                      @known_locations[i].direction)
  end
elsif Input.trigger?(Input::B)
  case @called_from
    when 0    # from map
      Sound.play_cancel
 
      # again turn the player around and exit
      opp_direction = case $game_player.direction
        when 2: 8 # down -> up
        when 4: 6 # left -> right
        when 6: 4 # right -> left
        when 8: 2 # up -> down
      end
 
      player_transition(@prev_map,
                        $game_player.x,
                        $game_player.y,
                        opp_direction)
    when 1    # from somewhere else
      # return somewhere else - CUSTOM CODE GOES HERE IF NECESSARY
  end
end
 
# move map according to velocities
refresh_window_position
 
@list_window.update
@map.update
  end
 
  def player_transition(map_id, x, y, dir)
# slightly custom transition script
$game_map.setup(map_id)
$game_player.moveto(x, y)
$game_player.set_direction(dir)   
$scene = Scene_Map.new
  end
 
  def terminate
super
@list_window.dispose
@map.dispose
  end
 
  def draw_map_icon(x, y, location)
if location.map_id != @prev_map || CURRENT_ICONS[1] == -1
  if !CUSTOM_ICONS
    if LOCATION_ICONS[0] == -1
      # if the icons should be greyed out icon is always selected_icon
      icon_code = LOCATION_ICONS[1]
 
      # enabled depends on whether the location is the selected one
      enabled = (location == @selected_location) ? true : false
    else
      # otherwise icon depends on whether the location is the selected one
      icon_code = (location == @selected_location) ? LOCATION_ICONS[1] : LOCATION_ICONS[0]
 
      # enabled is always true
      enabled = true
    end
  else
    # set custom icons to default if value is nil
    s_icon = (location.selected_icon == nil) ? LOCATION_ICONS[1] : location.selected_icon
    d_icon = (location.deselected_icon == nil) ? LOCATION_ICONS[0] : location.deselected_icon
    if d_icon == -1
      # same checks as above...
      icon_code = s_icon
      enabled = (location == @selected_location) ? true : false
    else
      icon_code = (location == @selected_location) ? s_icon : d_icon
      enabled = true
    end
  end
 
  @map.draw_icon(icon_code, x, y, enabled)
else
  # there are custom CURRENT location icons
  if CURRENT_ICONS[0] == -1
      # same checks as above
      icon_code = CURRENT_ICONS[1]
      enabled = (location == @selected_location) ? true : false
    else
      icon_code = (location == @selected_location) ? CURRENT_ICONS[1] : CURRENT_ICONS[0]
      enabled = true
  end
 
  @map.draw_icon(icon_code, x, y, enabled)
end
 
text = location.name   
# set new font properties only if the value isn't -1
# in which case defaults will be used
@map.contents.font.size = TEXT_SIZE unless TEXT_FONT == -1
@map.contents.font.name = TEXT_FONT unless TEXT_FONT == -1
 
# width and height set AFTER the above to get correct metrics
height = @map.contents.text_size(text).height+5
width = @map.contents.text_size(text).width
 
# the x+25 is to compenstate for the icon's width (24 pixels, I believe)
@map.contents.draw_text(x+25, y, width, height, text) unless SHOW_TEXT == false
  end
 
end
 
# ------------------------------------------------------------------------------
# ------------------------------- Location Class -------------------------------
# ------------------------------------------------------------------------------
 
class Location
  def initialize(map_id,
              name,
              direction,
              entry_coords,
              icon_coords,
              location_known,
              custom_icons = [nil, nil])
 
@name = name
@direction = direction
@entry_x = entry_coords[0]
@entry_y = entry_coords[1]
@map_id = map_id
@icon_x = icon_coords[0]
@icon_y = icon_coords[1]
@known = location_known
@deselected_icon = custom_icons[0]
@selected_icon = custom_icons[1]
  end
 
  # all can be modified
  attr_accessor :name
  attr_accessor :direction
  attr_accessor :entry_x
  attr_accessor :entry_y
  attr_accessor :map_id
  attr_accessor :icon_x
  attr_accessor :icon_y
  attr_accessor :known
  attr_accessor :selected_icon
  attr_accessor :deselected_icon
 
end

Ihr seid so ziemlich meine letzte Hoffnung.
Frag mich doch einfach was, mehr als fressen kann ich dich nicht ^o,o^

-> Homepage <-

 


 Bild des Monats

rooftop party

Views: 3615
By: papilion

 Umfrage

  • Wer soll das BdM gewinnen?
  • Dot Kandidat 1
  • 3 (25%)
  • Dot Kandidat 2
  • 1 (8%)
  • Dot Kandidat 3
  • 2 (16%)
  • Dot Kandidat 4
  • 0 (0%)
  • Dot Kandidat 5
  • 6 (50%)
  • Stimmen insgesamt: 12
  • View Topic

 Schnellsuche





SimplePortal 2.3.3 © 2008-2010, SimplePortal