I'm learning Java at the moment and am playing around with the Swing GUI as well as trying to understand how some of the larger roguelike dungeon builder algorithms work.
I came across this example in java for the algorithm -
And I was interested in modifying this code to display image tiles to a Swing JFrame -
//used to print the map on the screen
public void showDungeon(){
for (int y = 0; y < ysize; y++){
for (int x = 0; x < xsize; x++){
//System.out.print(getCell(x, y));
switch(getCell(x, y)){
case tileUnused:
System.out.print(" ");
break;
case tileDirtWall:
System.out.print("+");
break;
case tileDirtFloor:
System.out.print(".");
break;
case tileStoneWall:
System.out.print("O");
break;
case tileCorridor:
System.out.print("#");
break;
case tileDoor:
System.out.print("D");
break;
case tileUpStairs:
System.out.print("<");
break;
case tileDownStairs:
System.out.print(">");
break;
case tileChest:
System.out.print("*");
break;
};
}
if (xsize <= xmax) System.out.println();
}
}
I was wondering what the best method would be to achieve this - by creating a new grid in the JFrame? Can someone provide me with a sample code?
Thanks.