Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

show player map location

if you can plz tell me how to show player location, that would be awsome!

sorry if im posting too much helping stuff, im learning with a friend a lot on cms making :D
 
In the refresh method of the window use:
Code:
$data_map_infos = load_data("Data/MapInfos.rxdata")
self.contents.draw_text(X, y, width, height, $data_map_infos[$game_map.map_id].name)
 
guys im comfused.... What i want to do is make the showlocation in the top right of the screen. I want to edit menustatus to my liking. But how to i do make show location? I keep getting errors...
 

Vash

Member

I'm going to use the Window_Steps as an example:
Before:
Code:
class Window_Steps < Window_Base
#--------------------------------------------------------------------------
  # * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
#--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Step Count")
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
  end
end

After:
Code:
class Window_Steps < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
#--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    $data_map_infos = load_data("Data/MapInfos.rxdata")
    self.contents.draw_text(x, y, width, height, $data_map_infos[$game_map.map_id].name)
  end
end
 
You don't really need $data_map_infos variable. It's a global variable and will live during the game until the game shuts down, increasing unnecessary memory (though slightly, unnoticable). If you don't plan to use the variable in other classes, I suggest using local variable instead (that will be destroyed after exiting the method where it's declared, freeing some memory to be used). Don't forget that memory is not unlimited, and it's a critical factor for some users with old computers that are not powerful enough to handle huge amount of memory. (I can explain more why, but I think it will be way too technical for you, unless you really want to know why.)

Thus, replace $data_map_infos to data_map_infos or maybe just map_name (notice that I removed the $ sign from the variable name. $ sign tells us that it's a global variable, while variable which name doesn't begin with $ is a local variable) for better understandable name.

Better still, you don't need to create a variable at all. Shrink this code:

Code:
    $data_map_infos = load_data("Data/MapInfos.rxdata")
    self.contents.draw_text(x, y, width, height, $data_map_infos[$game_map.map_id].name)

into this:
Code:
self.contents.draw_text(x, y, width, height, load_data("Data/MapInfos.rxdata")[$game_map.map_id].name)

Although, if you need some processing of map name before displaying it, you should use a variable (remember, a local one should be enough for this case) to hold map name.
 
Okay, so I did all of the above but my map anme still doesnt appear in the menu. It's just blank.

Code:
#==============================================================================
# â–  Window_Steps
#------------------------------------------------------------------------------
#  メニュー画面で歩数を表示するウィンドウです。
#==============================================================================

class Window_Steps < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
#--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, height, load_data("Data/MapInfos.rxdata")[$game_map.map_id].name)
  end
end
 
11squall said:
Okay, so I did all of the above but my map anme still doesnt appear in the menu. It's just blank.

Code:
#==============================================================================
# â–  Window_Steps
#------------------------------------------------------------------------------
#  メニュー画面で歩数を表示するウィンドウです。
#==============================================================================

class Window_Steps < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
#--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, height, load_data("Data/MapInfos.rxdata")[$game_map.map_id].name)
  end
end

You also need to insert values for x, y, width and height
 
Code:
#==============================================================================
# â–  Window_Steps
#------------------------------------------------------------------------------
#  メニュー画面で歩数を表示するウィンドウです。
#==============================================================================

class Window_Steps < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
#--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 320, 160, 96, load_data("Data/MapInfos.rxdata")[$game_map.map_id].name)
  end
end
Still Nothing...
 
The text is not being displayed because you are drawing the text at (0,320) try this code instead

self.contents.draw_text(0, 32, 160, 96, load_data("Data/MapInfos.rxdata")[$game_map.map_id].name)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top