There is also a problem that arrises when the ball bounces back and forth between to non-removable bricks. A small random change in direction would fix that.
To avoid this kind of glitch, you should check the direction as well as location, like in the following:
private void checkWalls()
{
if( (deltaX < 0 && getX() < getImage().getWidth()/2) ||
(deltaX > 0 && getX() >= getWorld().getWidth()-140-getImage().getWidth()/2) )
{
Greenfoot.playSound("sounds/cling_1.wav");
deltaX = -deltaX;
}
if(deltaY < 0 && getY() <= getImage().getHeight()/2)
{
Greenfoot.playSound("sounds/cling_1.wav");
deltaY = -deltaY;
}
}
Also, the last few lines in your act method can be removed.
@trash1000, First, the UserInfo data can only be changed if you are logged in as that user. Second, if the scenario is programmed to save the score if, and only if, the new score is larger than the previous high score, then it needs to be adjusted somehow to allow a smaller value to be saved. If this is made a permanent option as 'erdelf' suggested, then only one update is neccessary. If this route is taken, I would also suggest a verification of deletion somehow.
It is possible to clear it, but it would take 2 updates to complete the process; plus it would take lux to play it between the updates. The first would be to add 'if (score > myInfo.getScore() [b]|| "lux".equals.myInfo.getUserName()[/b])' so when lux plays it, that score, no matter what it is, will be saved in the UserInfo data. And the second, to remove what was added; so a worse score by lux will not be saved.
I think the problem is due to the code to change each cell is in the act method which will not work properly there. The way it needs to work is that all cells need to be calculated to determine the next state for all the cells before changing any of them. And then, changing all of them at once. In other words, the press of the spacebar should be in the sub-class of world, and each time it is found to be pressed iterate through all the cells to figure out there next states, and then iterate though all the cells, changing to the states figured.
2012/8/16
BreakOut
2012/8/16
BreakOut
2012/8/15
BreakOut
2012/8/15
BreakOut
2012/8/15
BreakOut
2012/8/15
BreakOut
2012/8/14
Game of life
2012/8/10
Menu Demo
2012/8/10
Private Messaging