Hi, I'm having problems with making my scoreboard update every time someone misses in my game. All help is appreciated :). PS... the goal of the game is to shoot cannonballs over walls to hit the target. Here is my cannonball code and scoreboard code. Again, thanks :).
Cannonball
public class CannonBall extends Actor
{
protected int angle=0;
protected int power=100;
protected int misses=0;
protected StatusBoard statusBoard;
protected int xSpeed= 0;
protected int ySpeed= 0;
public static final int GRAVITY=2;
public CannonBall (int angle, int power, StatusBoard board)
{
power=(power*10)/25;
xSpeed=(int)(power*Math.cos(Math.toRadians(angle)));
ySpeed=(int)(power*Math.sin(Math.toRadians(angle)));
}
/**
* Act - do whatever the CannonBall wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
setLocation(getX()+xSpeed,getY()-ySpeed);
ySpeed=ySpeed-GRAVITY;
World cannonWorld = getWorld();
statusBoard.setValues (angle, power, misses);
if ( getY() > cannonWorld.getHeight() )
{
cannonWorld.removeObject(this);
misses=misses+1;
}
else
{
checkCollision();
}
}
public void checkCollision()
{
Target t = (Target) getOneIntersectingObject(Target.class);
if(t != null)
{
getWorld().removeObject(t);
getWorld().removeObject(this);
Greenfoot.playSound("Ding.mp3");
}
}
}
StatusBoard
public class StatusBoard extends Actor
{
private static final String angleLabel = "angle: ";
private static final String powerLabel = "power: ";
private static final String missesLabel = "misses: ";
protected GreenfootImage background = null;
private GreenfootImage box;
public StatusBoard ()
{
background = new GreenfootImage (100, 180);
background.setColor(new java.awt.Color(255, 255, 255, 200));
background.fillRect (0, 0, 150, 60);
setImage(background);
}
public void setValues(int angle, int power, int misses)
{
GreenfootImage img = new GreenfootImage (background);
img.setColor (java.awt.Color.BLUE);
img.drawString("Angle: " + angle, 10, 20);
img.drawString("Power: " + power, 10, 35);
img.drawString("Misses: " + misses, 10, 50);
setImage(img);
}
}
Thank you very much. All help is appreciated

