Chaos Project

RPG Maker => General Discussion => Troubleshooting / Help => Topic started by: Lore on March 06, 2011, 04:54:34 pm

Title: RPG Maker Map Question
Post by: Lore on March 06, 2011, 04:54:34 pm
So I was wondering how RPG Maker deals with the Map files and the whole workings behind how Maps are interpreted. I basically want to create a map in RPG Maker XP, and then use it for another game I'm creating in Java. So is there any way to have a programming language like Java interpret the RPG Maker map files? If not, that's fine, but is there a way to save the map file as a image such as a JPEG? If I take a screenshot of it, there's only so much I can fit on the screen (Say I had a map that's 50 x 50, I can't fit that all in one screenshot) and it will have those annoying gridlines too. If it comes to that, I can code the passability manually, but I just want the full image of the map at least (I don't want to crop together parts of screenshots)
Thanks!
Title: Re: RPG Maker Map Question
Post by: ForeverZer0 on March 06, 2011, 05:42:58 pm
The Custom Resolution script I wrote has a good example of how the map data is interpreted and drawn.

A map is actually a few seperate bitmaps on top of each other, which allows for having priority. They could be saved though. Grab a script that saves a Ruby bitmap object to a png file, then you can even use the Custom Resolution script and find the refresh method. Insert a little snippet there to have the png creator save each layer to file.

You can easily use a graphics editor to load them as layers and then flatten them, and there you go, a full size picture of the map.
Title: Re: RPG Maker Map Question
Post by: Lore on March 06, 2011, 05:52:31 pm
All right, awesome. Now correct me if I'm wrong, since you said it will convert it to a PNG with the layers to allow priority, does that mean I just have to write a small snippet of code in Java to interpret those layers? Or will I have to manually code all passable tiles?
Title: Re: RPG Maker Map Question
Post by: ForeverZer0 on March 06, 2011, 06:19:55 pm
The images will only help you denote priority, that is the "height" of each tile. This determines what overlaps what, etc, ect.

Passability determines if something can move through the tile or not. That data is stored in an array.
It is basically a linear array where each index corresponds to the tile with the respective ID. It uses a bit variable to determine which directions are passible/impassible from it. It is a little bit confusing, since IDs below 256 (?) are used only for the autotiles and all the combinations there.

It's kinda of hard to explain in a few short sentences, but if you really try to follow along in the Custom Resolution script, you can kinda start to see how it all comes together.
Title: Re: RPG Maker Map Question
Post by: Lore on March 06, 2011, 06:43:27 pm
Hm, I see. Well that poses a small problem. If Java, objects take "priority" in order they get drawn on screen. If I draw a circle and then a square, the square will overlap the circle until I redraw the circle. So if I draw the map as the background, and put the characters on top of it, they will overlap the map constantly since they will be redrawn over and over for their movement animations. I only need to draw the map once, so if they're separate images, there's no way of actually having the map overlap the character when they, say, go under a tree. Do you think it'll be easier to just draw the individual map pieces by hand and draw them as I see fit? That way I can control passability and priority with ease, but it will take a lot of graphical work.
Title: Re: RPG Maker Map Question
Post by: ForeverZer0 on March 06, 2011, 06:50:33 pm
I am not very familiar with Java. I experimented around with Sphere for about a week before I found RMXP, and that was before I ever even though of programming. So needless to say my experience with it is not much, don't sprites have a Z axis in Java? That is al the priorities are. Just different tiles drawn on different sprites with different Z values.
Title: Re: RPG Maker Map Question
Post by: winkio on March 06, 2011, 06:59:41 pm
Yes, draw everything individually, especially because you don't want to waste time drawing stuff that is off screen, as that would cause unnecessary lag.
Title: Re: RPG Maker Map Question
Post by: ForeverZer0 on March 06, 2011, 07:02:04 pm
It is already drawn off screen. Moving just causes the viewport to change and you see a different section of the bitmap.
Title: Re: RPG Maker Map Question
Post by: Lore on March 06, 2011, 07:04:53 pm
Well, I think it'll be easier to just draw each piece of the map individually. So I'd place rocks, grass, trees, buildings, etc all individually. That way I know what overlaps what, and I can easily make passability for each map by just checking if my character collides with certain objects. Thanks for the input guys, you can close this topic. Shit ton of sprite work, here I come.
Title: Re: RPG Maker Map Question
Post by: ForeverZer0 on March 06, 2011, 07:13:09 pm
Have you checked at out Sphere (http://www.gamediscovery.com/game-design/make-a-rpg-game-sphere-2d-rpg-engine.asp)? It uses Java, but also has tools for making maps using tilesets and setting passability easily.
Title: Re: RPG Maker Map Question
Post by: Lore on March 06, 2011, 07:34:26 pm
Correction, it uses JavaScript. Java and JavaScript are in no way related, with the former being a much more complex and more powerful language.
Thanks for this, but we will be creating our own Engine from scratch, because our game will be quite unique in some aspects. I'd rather not be limited to a pre-made engine :P
Title: Re: RPG Maker Map Question
Post by: ForeverZer0 on March 06, 2011, 08:20:56 pm
Is it JavaScript? I know they are not even related aside from the name. Like I said, it was a long time ago I last looked at it.  :P
Title: Re: RPG Maker Map Question
Post by: Lore on March 06, 2011, 08:47:58 pm
Haha, no worries :P
I think it'll be more flexible for us anyway if we create our engine. We have huge plans for this game in the future. It'll probably go commerical on Steam, and then we'll most likely add a Multiplayer feature and turn it into an MMORPG. So yeah, pretty sure it'll be better to play it safe with a custom engine.
Title: Re: RPG Maker Map Question
Post by: Zeriab on March 07, 2011, 02:06:29 am
I would personally use JRuby (http://www.jruby.org/) so I can load the RPG::Map object from the map files.

I suggest you check out RPG::Map and Tilemap in the help file.
It does not have all the information you need, but it does have some ^_^
RPG::MapInfo contains the information needed to build up the tree of maps in the editor which includes the name of the map. (MapInfos.rxdata)

If you cannot use JRuby (licensing issues?) I would instead write a Ruby script which reads the MapXXX.rxdata files and converts them into a format which is easier to write a Java parser for.
Here is my Table.to_s implementation which hopefully can give you ideas on how to structure the 3-dimensional table should you go this way.
class Table
  ##
  # Gives a special string representation. (For debugging purposes mostly)
  #
  def to_s
    if ysize == 1
      begin
        return to_s_1d
      rescue # In the rare case where you have a 2- or 3-dimensional
      end    # table with ysize = 1
    end
    if zsize == 1
      begin
        return to_s_2d
      rescue # In the rare case where you have a 3-dimensional table
      end    # with zsize = 1
    end
    return to_s_3d
  end
 
  ##
  # Returns a representation of the 1-dimensional table as a string
  # Assumes that the table is 1-dimensional. Will throw an error otherwise
  #
  def to_s_1d
    str = '['
    for i in 0...(xsize-1)
      str += self[i].to_s + ', '
    end
    str += self[xsize-1].to_s + ']'
    return str
  end
 
  ##
  # Returns a representation of the 2-dimensional table as a string
  # Assumes that the table is 2-dimensional. Will throw an error otherwise
  #
  def to_s_2d
    str = '['
    for j in 0...ysize
      str += "\n["
      for i in 0...(xsize-1)
        str += self[i,j].to_s + ', '
      end
      str += self[xsize-1,j].to_s + ']'
    end
    str += "\n]"
    return str
  end
 
  ##
  # Returns a representation of the 3-dimensional table as a string
  # Assumes that the table is 3-dimensional. Will throw an error otherwise
  #
  def to_s_3d
    str = '{'
    for k in 0...zsize
      str += '['
      for j in 0...ysize
        str += "\n["
        for i in 0...(xsize-1)
          str += self[i,j,k].to_s + ', '
        end
        str += self[xsize-1,j,k].to_s + ']'
      end
      str += "\n]"
    end
    str += '}'
    return str
  end
end


Quote from: ForeverZer0 on March 06, 2011, 07:02:04 pm
It is already drawn off screen. Moving just causes the viewport to change and you see a different section of the bitmap.

The main reason why custom resolution scripts don't fare well with big maps.

The default tilemap draw just what's needed plus some buffer around the visible area.
Take any custom resolution script and remove the Tilemap part from it. Increase the resolution and how the default tilemap works will be painfully obvious.

*hugs*
Title: Re: RPG Maker Map Question
Post by: Lore on March 07, 2011, 09:09:04 am
I'll look into that when I get home. The problem is that I don't know any Ruby, so writing a script to parse into Java is going to take additional time and hassle. I already wanted to learn C++ to help with ARC, so ANOTHER language is gonna be tedious. I'll try looking at JRuby and see if it makes sense to me, thanks! :D