This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gzuzfrk
Gzuzfrk wrote ...

2013/5/20

HELP PLEASE!!! project is due soon

Gzuzfrk Gzuzfrk

2013/5/20

#
So I'm trying to make a world where it already scrolls(which I have the scroll part done) And I want it to where a random number of aliens spawn in increments of 10 seconds at the bottom right side of the screen. I also want the number of aliens to increase as you get farther kind of like a survival game. Is there an easy code for that?
bourne bourne

2013/5/20

#
This should get you started: (Doing something every 10 seconds)
private long lastChecked = System.currentTimeMillis();
private int increment = 10;

public void act()
{
    long currentTime = System.currentTimeMillis();
    if ((currentTime - lastChecked) / 1000 >= increment)
    {
        // Spawn Alien

        lastChecked = currentTime;
    }
}
You need to login to post a reply.