Could someone provide a link to a good Tile Engine example, with file saving. I know there are alot of Tile Engine examples in different languages, but I was hoping for a simple Java example, that that can save a map, which is usually an array. The shortest amount of code possible, or a tutorial would be best. For graphics, I would like to use LWJGL.
How about a simple text file where each character represents a tile?
0000000000
4003001301
1111001111
4000002000
1111111111
//read file
int y = 0;
for(String line : lines) {
for(int x = 0; x < lines.length(); x++) {
switch(lines.charAt(x)) {
case '1':
add(new Block(x,y));
break;
case '2':
add(new Player(x,y));
break;
case '3':
add(new Coin(x,y));
break;
case '4':
add(new Enemy(x,y));
break;
}
}
y++;
}
depends, what all are you going to have on your map? cuase that could change things.
if just walls, then make a 2d boolean array, and every step just check if spot is “blocked”. simple enough :).
Thank you for providing this!
@ antelopeDJ
A i just finished explaining my more complete example:
Even better! The code provided in this thread helped me to understand how it worked, and yours seems to build on it. appreciate