2D Map Loading

Started by liamsdomain, August 15, 2011, 21:20:10

Previous topic - Next topic

liamsdomain

I am making my first game in java and I was wondering if someone could help me with map loading. I'm making a 2D game (similar to the style of the pokemon games, but with a different goal in the game) that has random generated worlds, I want to store the worlds in a text file with some sort of format like...

8888888888
8088088888
8008088088
8800008088
8808888088
8800000088
8888888888

With the 8's being non-passable objects like walls and the 0's being passable objects like the ground.

I am drawing a blank on how I could load and save these files easily in JAVA and then store them in an Array of some kind.

Thanks in advance.

Fool Running

Read in the text file line-by-line and then look at each character in the string. If the character is an '8', then put a value (easiest would be an 8 ) into the array at the same location (i.e. line number/character number).

To save back to the file, just reverse the above logic.

This is basic programming stuff. You might want to brush up on programming basics before you attempt a game.

EIDT: Google is also your friend (quick search for "java reading text file": http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml)
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D