I am trying to get my enemies to jump at a random interval.
This is what I have.
public class Jumper extends Enemy
{
int j = 0;
boolean onGround;
private static final int jumpStrength = 14;
GreenfootImage left = new GreenfootImage("JumperLeft.png");
public void act()
{
j++;
if(j == 100);
{
if (j <= 20) {
jump();
}
else if (j >= 25)
{
fall();
}
if (j >= 250) {
j=0;
}
}
}
public void jump()
{
setVSpeed(-jumpStrength);
fall();
}
private void checkFall()
{
if (onGround()) {
setVSpeed(0);
}
}
}