OK so I have this applet I am making and I want it to generator a world according to a number...
Here it is:
public int[][] loadBoard(int map) {
if (map == 1) { int[][] board = { {
2,2,24,24,24,24,24,3,3,0,0,0,1 },
{ 2,2,24,23,23,23,24,1,3,0,0,0,1 },
{ 1,1,24,23,23,23,24,1,3,3,3,3,1 },
{ 1,1,24,24,23,24,24,1,1,1,1,3,1 },
{ 1,1,1,1,7,1,1,1,1,1,1,3,1 },
{ 5,1,1,1,7,7,7,7,7,1,1,1,1 },
{ 6,3,3,1,3,3,3,1,7,7,7,3,1 },
{ 6,3,3,1,3,1,1,1,1,1,7,1,1 },
{ 3,3,1,1,1,1,1,1,1,1,7,1,1 } };
}else{
int[][] board = {
{ 1,1,1,1,1,24,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,24,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,24,1,1,24,1,1,1,1 },
{ 1,1,1,1,1,24,1,1,24,1,1,1,1 },
{ 1,1,7,1,1,24,24,24,24,1,1,1,1 },
{ 1,1,7,1,1,24,1,24,1,1,1,1,1 },
{ 1,1,1,1,1,24,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,24,1,1,1,1,1,1,1 },
{ 1,3,3,1,1,24,1,1,1,1,1,1,1 },
}; } return board; }
and to call it I use:
board = loadBoard(1);
I put that in the init() method. Then that way I can call maps upon the number inside loadBoard(). However, when I start my game I get nullpointer exception and I KNOW for a FACT that its something to do with the code I just showed you above. It's probably some rookie mistake I am doing.. maybe you can help?