let me try again.
i think it should work now
{if (Greenfoot.isKeyDown("A"))
Greenfoot.setWorld(new LB_HeavenWorld());
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
import java.util.Calendar;
/**
* Displays a digital clock in HH:MM:SS format.
*/
public class CountdownClock extends Actor
{
private int width = 60; // Dimensions of the display
private int height = 20;
private int prevSecond = -1;
private int counter = 0;
/**
* The constructor creates the actor's image.
*/
public CountdownClock(int startSeconds)
{
counter = startSeconds;
GreenfootImage image = new GreenfootImage(width, height);
image.setColor(Color.WHITE);
image.fill();
image.setColor(Color.BLACK);
image.drawRect(0, 0 ,width - 1, height - 1);
setImage(image);
updateDisplay(counter + ".0");
}
public CountdownClock()
{
this(15);
}
/**
* The clock is tick'd on every act() call, but the display changes
* only when the second's increments.
*/
public void act()
{
if (counter > 0)
{
updateDisplay(tick());
}
}
/**
* Increment the display string for the clock.
*/
public String tick()
{
// Compose new display string
Calendar calendar = Calendar.getInstance();
int sec = calendar.get(Calendar.SECOND);
int tsec = calendar.get(Calendar.MILLISECOND) / 100;
if (counter == 0)
{
return("0.0");
}
if (sec != prevSecond )
{
prevSecond = sec;
counter = counter - 1;
}
return(counter + "." + tsec);
}
/**
* Update the clock with the new time string.
*/
public void updateDisplay(String newTime)
{
// x and y relative to the image. baseline of leftmost character.
int x = 5;
int y = 15;
// Repaint the clock display
GreenfootImage image = getImage();
image.setColor(Color.WHITE);
image.fillRect(1, 1, width-2, height-2); // "erase" the display
image.setColor(Color.BLACK);
image.drawString(newTime, x, y);
setImage(image);
}
/**
* Returns the current value of the clock.
*/
public int getCounter()
{
return counter;
}
}