So i am doing the White Blood Cell practice in the book and i am to the point where i am subtracting the score whenever the Virus of Bacteria touches the wall but whenever they touch the wall they set the score to -15 for bacteria and -100 for a virus instead of subtracting that number from the current score.
Code for adding score when you "eat" a bacteria and Virus
Code for subtracting score when the bacteria touches the edge
code for subtracting score when the virus touched the edge
By the way i have kind of changed what the book tells you to do an i have kept the scoring mechanisms in there respecive classes instead of moving it all to the Bloodsteam( the world)
private void checkCollision()
{
if(isTouching(Virus.class))
{
removeTouching(Virus.class);
score = score + 20;
getWorld().showText("Score" + score,80,25);
}
if (isTouching(Bacteria.class))
{
removeTouching(Bacteria.class);
score = score + 10;
Greenfoot.playSound("slurp.wav");
getWorld().showText("Score:" + score,80,25);
}
}if (getX() == 0)
{
score = score - 15;
getWorld().showText("Score:" + score,80,25);
getWorld().removeObject(this);
}if (getX() == 0)
{
score = score - 100;
getWorld().showText("Score:" + score,80,25);
getWorld().removeObject(this);
}

