I now it is possible to say if actor eat let say 10 snakes
greenfoot.stop
but is it possible to stop the game in 60 seconds I need really help because I have no idea
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class tijd extends Actor
{
public void act()
{
System.currentTimeMillis();
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class tijd extends Actor { public void act() { System.currentTimeMillis(); } }
gameover();import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class tijd extends Actor
{
public void act()
{
if (System.currentTimeMillis(1000));
gameOver();
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Example
*
* @author Michionlion
* @version 4/16/2012
*/
public class myWorld extends World {
private long time;
/**
* Constructor for objects of class myWorld.
*
*/
public myWorld() {
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
time = System.currentTimeMillis(); // current time elapsed from January 1, 1970 in milliseconds
}
public void act() {
if (time < time + 200) {
// call gameover method, and stop greenfoot
Greenfoot.stop();
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class tijd extends Actor
{
private long time;
public tijd()
{
super(700, 600, 1);
time = System.currentTimeMillis();
}
public void act()
{
if (time < time + 1000)
Greenfoot.stop();
}
}import greenfoot.*;
public class TimeChecker extends Actor {
long initialTime;
public TimeChecker() {
initialTime = System.currentTimeMillis();
}
public void act() {
if(System.currentTimeMillis() > initialTime + 60000) {
//Put your code here that you want to happen when the game ends
Greenfoot.stop();
}
}
}