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


1 2 3 4 5 6 7 8 9 10 11 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class tijd extends Actor { public void act() { System.currentTimeMillis(); } } |
1 2 3 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class tijd extends Actor { public void act() { System.currentTimeMillis(); } } gameover(); |
1 2 3 4 5 6 7 8 9 10 11 12 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class tijd extends Actor { public void act() { if (System.currentTimeMillis( 1000 )); gameOver(); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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(); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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(); } } } |