×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Eire
    Posts
    182

    Loading map data.

    I'm about to start developing a side scroller and i'm looking into ways of loading in the level maps and storing them.

    I've found that the 2 most recommended ways are using a binary file and somebody also mentioned in a post that you can use a .png to hold the map data.

    I understand how you could use a png to hold the data.

    a 50*50 pixel png would represent a 50*50 tile and map and the colour of each pixel could represent what is on each particular tile.

    But how to you parse this data?

    Thanks for your time.

    Brian

  2. #2
    Regular Contributor
    Join Date
    Jun 2003
    Location
    Hungary
    Posts
    414
    Store all tile in one big .png, instead of using many small. Note: On some device there is a maximum width of image (?256px?), but no restriction on image height.
    The image map isn't another image. Use any coding way that you like eg. simple text, that desribe each tile by a letter. You can parse it easily.

  3. #3
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Eire
    Posts
    182
    I think there is a way to store your level maps as .pngs the parse the image pixle by pixel.

    Well so i though anyways..... dont know how it is done though.

    Somebody mentioned it before but didnt explain how you would pull it off.

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    You could store a map in a PNG... but you can't extract the pixel data with the MIDP-1.0 API, so you end up with code that only works on some phones. Depending on the phone, the colours will get converted to whatever range of colours the phone likes, so it would be hard to ensure that you get the right colour values back.

    It's not a good plan, in my opinion. Besides, there's no need; anything you place in the JAR goes through the same compression algorithm as is used for PNGs anyway.

    A text file is much simpler. If you want something slightly smaller, write a J2SE program to read the text file, then convert it to a byte array, and dump the byte array to a file. Then you can just load the information straight into a byte array in your game.

    Graham.

  5. #5
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Eire
    Posts
    182
    OK will not go with the .png method.

    Thats a good idea Graham... write a program to make a byte array...will get down to it once the pigs are fed and ready to fly
    :-D

    Will go with a simple .txt map then.

    Thanks
    Brian

  6. #6
    Regular Contributor
    Join Date
    Mar 2003
    Location
    USA, FL
    Posts
    148
    Yeah, if you have a pretty big resource file, you may save space by using bits: for instance, 4 bits will give you numbers from 0-15.

    Dima
    Game Artisis, LLC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×