• Advertisement
Sign in to follow this  

Making maps from images..

This topic is 2257 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am making a 2d rpg game and I wanted to think of a way to make maps easyer. On my journey I found This video

Near the end you see him making a pixel map in some kind of image editing program and importing it to the game and automatically initializing tiles based on what the image shows.

Please can you tell me what this is called or give me a link to a tutorial for Java?

Thanks in advance.

Gen.

Share this post


Link to post
Share on other sites
Advertisement
Well, i don't know if this technique has a name, but i if i am correct:

what he is doing there is represent a set of colors as a sprite, for example the black color (0x000000) is represented as an empty tile and the white color (0xFFFFFF) is represented as a the "star" tile.

you just have to understand how RGBA works :)

Share this post


Link to post
Share on other sites
You would need to load your image into a surface, then read it pixel by pixel determining the color value.
then map those color values to tile values.

Share this post


Link to post
Share on other sites
Also note, if you have fewer than 255 tiles you can use the three other values as other data. There are a lot of neat things you can do if you choose to represent RGBA as something other than colors.

Eg: R can represent a tile while G represents the height and A is the id for a creature when it's non-zero. When I first understood this concept, I had a lot of fun altering game maps using Photoshop's filters and other image editing tools.

As an extra bonus, you can easily write shaders to manipulate and create maps. This is useful for quickly executing map generation algorithms.

Share this post


Link to post
Share on other sites
I'd be extremely careful in doing that. Mapping tiles... to unique numeric ids... so they can be stored in RGBA... so they can be loaded... uhm, I'm not quite on it. I'd say it's just easier to use the file id directly.
It's not like the RGBA representation is WYSIWYG. A matrix of file names isn't as well but at least you won't have to go crazy figuring out the ID mapping.


Shaders to create maps? Mangling arbitrary numeric, integer ids? I guess I don't quite get it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement