I am making boulderdash game and m stuck in changing and retrying the level in the game.. Here is my code !!
public ReadFileReplace()
{
imageObject();
replaceIcon();
}
public void imageObject()
{
objwall = new ImageIcon("wall_32.png");
other more images
}
public void replaceIcon()
{
try
{
FileReader fileRead = new FileReader("level"+level+".txt"); --- i think the problem is here!!
BufferedReader buffread = new BufferedReader(fileRead);
String lineRead = buffread.readLine();
int x=0;
while(lineRead!=null)
{
for(int y=0;y<20;y++)
{
fileReadArray[x][y] = new JLabel();
c=lineRead.charAt(y);
if(c=='W')
{
fileReadArray[x][y].setIcon(objwall);
mapPanel.add(fileReadArray[x][y]);
}
.
.
.
.
And other codes!!
}
lineRead = buffread.readLine();
x++;
}
buffread.close();
fileRead.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
and on the other class, i called imageIcon() inside retry () method.......please help me !!