private int countdowntime = 4; private int countdowndelay = 0; private int countdownreach = 250; private boolean wait = false; public void countdown() { while (countdowntime > 0) { wait = true; countdowndelay++; if (countdowndelay >= countdownreach) { countdowntime--; Greenfoot.playSound("Countdown.mp3"); countdowndelay = 0; String text = ""; text = Integer.toString(countdowntime); this.showText(text,this.getHeight()/2,this.getWidth()/2); if (countdowntime == 1) { countdownreach = Greenfoot.getRandomNumber(250); countdownreach = countdownreach+250; } if (countdowntime == 0) { countdownreach = 250; } } } countdowntime = 4; started = true; }