I was wondering if there is a way you could increase your score counter by more than one? For example, when a snake eats a cherry, I want it to increase by one, but when it eats a blueberry, I want it to increase by 5.
This is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public class Score extends Actor { private int score = 0 ; public Score(){ updateImage(); } /** * Act - do whatever the Score wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void updateImage() { setImage( new GreenfootImage( "Score : " + score, 20 ,greenfoot.Color.BLACK, greenfoot.Color.WHITE)); } public void addScoreCherries(){ score++; updateImage(); } } |