Hi there,
Im stuck on my assigment :s the problem is everything is compiling but the program is not doing anything.
1st I need to call repaint() if slideBlock return true and I don't know how to.
2nd problem not sure if the slideBlock method is 100% right.
boolean slideBlock(int thisCol, int thisRow)
{
if(thisCol<0 || thisCol>=empty_col)
return false;
if(thisRow<0 || thisRow>=empty_row)
return false;
if ( (Math.abs(thisRow-empty_row) == 1) && (Math.abs(thisCol-empty_col) > 0) || ((Math.abs(thisRow-empty_row) != 1) && (Math.abs(thisCol-empty_col) > 0)) )
{
puzzle[empty_col][empty_row] = puzzle[thisCol][thisRow];
control[empty_col][empty_row] = control[thisCol][thisRow];
puzzle[thisCol][thisRow] = null;
empty_col = thisCol;
empty_row = thisRow;
return true;
}
else
{
return false;
}
mouse event
public void mouseClicked(MouseEvent event)
{
int thisCol = getCol(event.getX());
int thisRow = getRow(event.getY());
if (buttNum == 1)
{
myModel.slideBlock(thisCol,thisRow);
}
System.out.println("you clicked in column " + thisCol + " and Row " + thisRow);
}
I just posted the 2sections Im stuck in let me know if you need the whole 2 files.
Thanks in advance
Pedro