Cell Values question
Hi, I am a first year programming student and I have hit a roadblock in one of my assignments. Any help will be greatly appreciated.
So I am making the penguin game (simpler version) found online:
http://www.miniclip.com/games/penguin-push/en/
The problem I am having is that once the penguin has moved a block to a goal he can move it again off of it and the goal should be back to its original color. However, my issue is that once i move a block onto the goal and move it off, the cell for where the goal is supposed to be turn gray, the background color.
Here is the method that checks for all of this. Can anyone please help. Thanks in advance.
// There is a movable block at cell location (blockX, blockY). The direction
// in which we're trying to move is (dx, dy). If the block can be moved,
// then the block should get a new location, making the cell array
// location it used to be in a FREE_CELL. Returns true when the block
// is moved (and thus the player can move too). Returns false when the
// block cannot be moved (and thus the player should stay in the same
// location). Does not change the location of the player itself.
privateboolean handleMovableBlock(int dx,int dy,int blockX,int blockY){
int newY = blockY + dy;
int newX = blockX + dx;
if ((newY < getRows() && newX < getColumns())
&& (cells[newY][newX] != CellValues.MOVABLE_BLOCK)
&& (cells[newY][newX] != CellValues.OCCUPIED_CELL)){
if (cells[blockY][blockX] != CellValues.GOAL)
cells[blockY][blockX] = CellValues.FREE_CELL;
cells[newY][newX] = CellValues.MOVABLE_BLOCK;
if(cells[newY][newX] == CellValues.MOVABLE_BLOCK_ON_GOAL)//trying to change color back to original if block is moved past
cells[blockY][blockX] = CellValues.GOAL;
returntrue;
}
returnfalse;
}

