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

2019/7/14

i also have this problem if any one can have a look that would be great

Coltz Coltz

2019/7/14

#
import greenfoot.*;

/**
 * Write a description of class smallBlue here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class smallBlue extends Targets
{
    public void act()
    {
        smallBlue();
        yellowCubeChance();
    }

    public void yellowCubeChance()
    {
        int yellowCubeChance = Greenfoot.getRandomNumber(1);
        if(yellowCubeChance == 1)
        {
            yellowCube yellowcube = new yellowCube();
            getWorld().addObject(new yellowCube() , getX(), getY());
            setRotation(90);
            move(5);
        }
    }

    public void smallBlue()
    {
        Actor smallBlue = getOneIntersectingObject(smallBlue.class);
        if(smallBlue != null)
        {
            smallBlue smallblue = new smallBlue();
            getWorld().removeObject(this);
        }
    }
}

danpost danpost

2019/7/15

#
Remove line 34 (does nothing but create an unused object). The condition on line 20 will never evaluate true as only zero (0) can be randomly returned using one (1) on line 19.
You need to login to post a reply.