hey everyone, I just getting started with greenfoot couple weeks ago, and here's my code:
actually, all I'm trying to do is get that stage1 method to run correctly because it won't! due to an arithmetic exception.
I really appreciate any help. thanks
*sorry for the mess code
public class Obstacle extends Actor
public Obstacle(int speed,int damage,int spawntimer)
{
setspeed(speed);
setdamage(damage);
}
public void setspawntimer(int spawntimer) {this.spawntimer = spawntimer;}
public int getspawntimer(){return this.spawntimer;}
public class Stone extends Obstacle
public Stone()
{super(1,1,2);getImage().scale(40,40);}
//world is where the problem starts
public class MyWorld extends World
int stonetime = stone.getspawntimer();
int mushroomtime = mushroom.getspawntimer();
private boolean spawntimer(int s)
{return time%(60*s) == 0;}
public void stage1()
{
if (spawntimer(stonetime))
{
addObject(new Stone(), Greenfoot.getRandomNumber(600),20);
}
}
public void act()
{
time++;
stage1();
}
