1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import greenfoot.*; import java.awt.Color; public class Score extends Actor { static int best = 0 ; int score = 0 ; public void addedToWorld(World w) { act(); } public void act() { setImage( new GreenfootImage( "Score: " + score + "\nBest: " + best, 20 , Color.WHITE, Color.BLACK)); setLocation(Space.width - (getImage().getWidth()/ 2 ), getImage().getHeight()/ 2 ); if (Space.started) { score++; if (best < score) best = score; } } } |

